开发者

Is this a jquery.live() side effect?

开发者 https://www.devze.com 2023-01-16 19:40 出处:网络
I\'m new to jq开发者_运维知识库uery. When I was using .live(\'click\', handler) instead of .click(handler), I found the event handler can be triggered even though the object is disabled! Is this a bug

I'm new to jq开发者_运维知识库uery. When I was using .live('click', handler) instead of .click(handler), I found the event handler can be triggered even though the object is disabled! Is this a bug of .live() all it is an anticipated behavior? And if do not want the side effect, what should I do? Thanks!


Looks like a bug.


As an alternative/workaround, use this instead:

$('#myForm').delegate('#myButton', 'click', handler);

Here's a fiddle showing that this does produce the desired results: http://www.jsfiddle.net/YcS8A/

0

精彩评论

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