Can I find events bound on an element with jQuery?

I bind two event handlers on this link: <a href=”#” id=’elm’>Show Alert</a> JavaScript: $(function() { $(‘#elm’).click(_f); $(‘#elm’).mouseover(_m); }); function _f(){alert(‘clicked’);} function _m(){alert(‘mouse over’);} Is there any way to get a list of all events bound on an element, in this case on element with id=”elm”? 9 Answers 9

HTML5 dragleave fired when hovering a child element

The problem I’m having is that the dragleave event of an element is fired when hovering a child element of that element. Also, dragenter is not fired when hovering back the parent element again. I made a simplified fiddle: http://jsfiddle.net/pimvdb/HU6Mk/1/. HTML: <div id=”drag” draggable=”true”>drag me</div> <hr> <div id=”drop”> drop here <p>child</p> parent </div> with the … Read more

jQuery $(document).ready and UpdatePanels?

I’m using jQuery to wire up some mouseover effects on elements that are inside an UpdatePanel. The events are bound in $(document).ready . For example: $(function() { $(‘div._Foo’).bind(“mouseover”, function(e) { // Do something exciting }); }); Of course, this works fine the first time the page is loaded, but when the UpdatePanel does a partial … Read more

How to distinguish between left and right mouse click with jQuery

How do you obtain the clicked mouse button using jQuery? $(‘div’).bind(‘click’, function(){ alert(‘clicked’); }); this is triggered by both right and left click, what is the way of being able to catch right mouse click? I’d be happy if something like below exists: $(‘div’).bind(‘rightclick’, function(){ alert(‘right mouse button is pressed’); }); 2Best Answer 21 As … Read more

jQuery.click() vs onClick

I have a huge jQuery application, and I’m using the below two methods for click events. First method HTML <div id=”myDiv”>Some Content</div> jQuery $(‘#myDiv’).click(function(){ //Some code }); Second method HTML <div id=”myDiv” onClick=”divFunction()”>Some Content</div> JavaScript function call function divFunction(){ //Some code } I use either the first or second method in my application. Which one … Read more

How to debug JavaScript / jQuery event bindings with Firebug or similar tools?

I need to debug a web application that uses jQuery to do some fairly complex and messy DOM manipulation. At one point, some of the events that were bound to particular elements, are not fired and simply stop working. If I had a capability to edit the application source, I would drill down and add … Read more

How to detect escape key press with pure JS or jQuery?

Possible Duplicate: Which keycode for escape key with jQuery How to detect escape key press in IE, Firefox and Chrome? Below code works in IE and alerts 27, but in Firefox it alerts 0 $(‘body’).keypress(function(e){ alert(e.which); if(e.which == 27){ // Close my modal window } }); 10 s 10 Note: keyCode is becoming deprecated, use … Read more