Reputation: 5183
I have a jQuery accordion like this:
<div id="accordion">
<h3>Log Output</h3>
<div id="result" class="logStyle" />
</div>
I init it in my javascript like this (in the document ready function):
$("#accordion").accordion({
header: "h3",
collapsible: true,
active: false
});
I'm trying to prevent my one item from opening when the user hits 'Enter'. I've tried removing the keypress:
$("#accordion").removeAttr("keypress");
Handling the event directly:
$("#accordion").bind('keypress', function(e) {
e.stopPropagation();
}});
and
$("#accordion").keypress(function (evt) {
var charCode = evt.charCode || evt.keyCode;
if (charCode == 13) {
return false;
}
});
But no matter what I do, hitting enter opens the accordion. How can I disable this?
Upvotes: 0
Views: 1559
Reputation: 869
$('#accordion').unbind('accordion');
Better use .on()
and .off()
, 'cause you're able to delegate events with this functions, too. :)
http://api.jquery.com/on/
http://api.jquery.com/off/
Upvotes: 1