I’ve been struggling over this for almost 5 hours and finally I’ve got a clue.
Here’s a code that I’m using on my website:
jQuery(document).ready(function(){
jQuery(".thumbnail").bind("click",function(){
var elem = jQuery(this);
if((elem).data('test')) {
alert('data is test');
elem.data('test',false);
}
else {
alert('data is not test');
elem.data('test',true);
}
});
});
Here’s jfiddle.
When you click on “thumbnail” it should fire one alert (either “data is test” or “data is not test”).
When I try the same exact code on my WordPress page (localhost) it shows TWO alerts one after another – “data is not set” and then “data is set” – what may cause this strange behavior?
Unfortunately I can’t provide the source. I’m hoping this is something common and maybe some jQuery wizard will know the answer? Somehow…?
I don’t think it’s a jQuery bug, but one of the following: