jQuery click event fires twice

Today I had an issue with jQuery where a listener for a ‘click’ event was being triggered twice.
With the following code, I would get two logs in the console:

jQuery(document).ready(function(){
	jQuery('#button').click(function(){
		console.log(1);
		return false;
	});
});

I was even trying the jQuery(function() { }); method, but I would still get the same results.

After some debugging, I figured out that if I moved that javascript to be inside the <head></head> tag instead of the <body></body> tag which is where I originally had it, that would fix the problem.

Hope it helps,
Rafael Corral
Lead developer

STAY UP TO DATE

Sign up today to stay informed with industry news & trends

[mc4wp_form id=26062]