[英]jquery event listener on checkbox disable
I am currently looking for an event listener for input type=checkbox that fires when disable state changes 我目前正在寻找输入类型=复选框的事件侦听器,当禁用状态更改时将触发该事件
I do not want to add the event to the first trigger which changes the checkbox state. 我不想将事件添加到更改复选框状态的第一个触发器。 It must be independent, for the trigger may change.
它必须是独立的,因为触发器可能会改变。
What I have tried so far: 到目前为止我尝试过的是:
$(function(){
$('.trigger').live('click', function(){
$('.eventbox').attr('disabled','disabled');
});
$('.eventbox').live('change', function(){
alert('state changed');
});
});
Unfortunately change doesn't work. 不幸的是,更改无效。
thank you for your help. 谢谢您的帮助。 jesse
杰西
can you put a trigger on the thing that does the checkbox disabling? 您可以对复选框禁用的东西添加触发器吗? By that I mean, if you have some button that as a side effect disables some checkboxes on click, could you tack you listener onto the click of the button?
我的意思是,如果您有一些按钮,但它的副作用是禁用了单击时的某些复选框,您能否将按钮设置为监听器?
Try this. 尝试这个。 I think you really want to track checking/unchecking of checkbox and not enabling/disabling.
我认为您真的想跟踪复选框的选中/取消选中,而不是启用/禁用。
$(function(){
$('.trigger').live('click', function(){
$('.eventbox').removeAttr('checked');
});
$('.eventbox').live('change', function(){
alert('state changed');// this will be fired only if state was checked
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.