Jquery — Click event fires twice.

by Yuji

I had an issue with jquery where the click event fires twice per click.

With the following code, I would get the alert fired twice.

$("div").click( function()  { alert('clicked');} ) 

I narrowed down the problem to having the DOM Ready function inside of my HTML <body></body> tag.

So.. make sure all of your jquery code is inside one document.ready() or $(function() { }); (the jquery shortcut)

I reproduced this error and having two sets of $(function() {}); was no problem inside the <head></head> tags, but as soon as it goes in the <body></body> the problem appeared.