Questions tagged [jquery-events]

These methods are used to register behaviors to take effect when the user interacts with the browser, and to further manipulate those registered behaviors.

These methods are used to register behaviors to take effect when the user interacts with the browser, and to further manipulate those registered behaviors.

5186 questions
1114
votes
13 answers

How can I trigger the same function from multiple events with jQuery?

Is there a way to have keyup, keypress, blur, and change events call the same function in one line or do I have to do them separately? The problem I have is that I need to validate some data with a db lookup and would like to make sure validation is…
shaneburgess
  • 15,702
  • 15
  • 47
  • 66
826
votes
19 answers

How can I detect pressing Enter on the keyboard using jQuery?

I would like to detect whether the user has pressed Enter using jQuery. How is this possible? Does it require a plugin? It looks like I need to use the keypress() method. Are there browser issues with that command - like are there any browser…
chris
  • 20,791
  • 29
  • 77
  • 90
674
votes
10 answers

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); …
Mithun Sreedharan
  • 49,883
  • 70
  • 181
  • 236
619
votes
18 answers

jQuery.click() vs onClick

I have a huge jQuery application, and I'm using the below two methods for click events. First method HTML
Some Content
jQuery $('#myDiv').click(function(){ //Some code }); Second method HTML
Techie
  • 44,706
  • 42
  • 157
  • 243
618
votes
15 answers

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…
Jaanus
  • 17,688
  • 15
  • 65
  • 110
618
votes
20 answers

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…
Sinan
  • 11,443
  • 7
  • 37
  • 48
606
votes
15 answers

Using jQuery to test if an input has focus

On the front page of a site I am building, several
s use the CSS :hover pseudo-class to add a border when the mouse is over them. One of the
s contains a
which, using jQuery, will keep the border if an input within it has focus.…
bloudermilk
  • 17,820
  • 15
  • 68
  • 98
486
votes
18 answers

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…
Herb Caudill
  • 50,043
  • 39
  • 124
  • 173
432
votes
41 answers

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:…
pimvdb
  • 151,816
  • 78
  • 307
  • 352
383
votes
9 answers

Can I find events bound on an element with jQuery?

I bind two event handlers on this link: Show Alert JavaScript: $(function() { $('#elm').click(_f); $('#elm').mouseover(_m); }); function _f(){alert('clicked');} function _m(){alert('mouse over');} Is there any way to…
Praveen Prasad
  • 31,561
  • 18
  • 73
  • 106
348
votes
29 answers

jQuery click events firing multiple times

I'm attempting to write a video poker game in Javascript as a way of getting the basics of it down, and I've run into a problem where the jQuery click event handlers are firing multiple times. They're attached to buttons for placing a bet, and it…
Gregory Fowler
  • 3,623
  • 2
  • 13
  • 7
315
votes
26 answers

How to wait for the 'end' of 'resize' event and only then perform an action?

So I currently use something like: $(window).resize(function(){resizedw();}); But this gets called many times while resizing process goes on. Is it possible to catch an event when it ends?
Rella
  • 65,003
  • 109
  • 363
  • 636
304
votes
14 answers

jQuery callback on image load (even when the image is cached)

I want to do: $("img").bind('load', function() { // do stuff }); But the load event doesn't fire when the image is loaded from cache. The jQuery docs suggest a plugin to fix this, but it doesn't work
Tom Lehman
  • 85,973
  • 71
  • 200
  • 272
276
votes
21 answers

Getting value of select (dropdown) before change

The thing I want to achieve is whenever the