开发者

JQuery, add two handlers for the same event

开发者 https://www.devze.com 2023-03-13 17:18 出处:网络
I have several text inputs in my page. They have different classes added to them. Depending on the class they each have, I add开发者_如何学运维 an onchange event handler. Everything worked OK, until t

I have several text inputs in my page. They have different classes added to them. Depending on the class they each have, I add开发者_如何学运维 an onchange event handler. Everything worked OK, until they all shared one common class, then I add common onchange handler again. The first oen gets overwritten.

Is there a way to add another handler and not overwrite the precious one?


They should not get overwritten.

You should be able to do:

$('.className').change(function(){
    alert('here')
})

$('.className').change(function(){
    alert('over here')
})

And you should see both alerts

See fiddle: http://jsfiddle.net/maniator/JEyTM/


All right, I resolved my issue following this tutorial.

It was actually related to a this Farbtastic bug

0

精彩评论

暂无评论...
验证码 换一张
取 消