Kanaka k
Kanaka k

Reputation: 95

How to write code for firefox click event using Jquery

Click event is not working on firefox but it's working in chrome. why?

setTimeout(function(){ 

$("#id").prev('div').find('button').find('div.classname').click(function(){
alert("Testing");
});


}, 3000);

Upvotes: 0

Views: 67

Answers (1)

jwebb
jwebb

Reputation: 1149

If you bind the click event to the button itself, and not the div inside it, that will work :

setTimeout(function(){ 

$("#id").prev('div').find('button').click(function(){
alert("Testing");
});


}, 3000);

Fiddle http://jsfiddle.net/aur7dwL4/

However, as noted above by @Barmar, having a div inside of a button is invalid HTML markup.

Upvotes: 1

Related Questions