【发布时间】:2013-03-23 21:21:25
【问题描述】:
我有一个 html 控件,需要检测它的禁用状态何时发生变化。
我试过了:
cb.on("change", function() {
if(cb.is(":disabled")) {
// the control is disabled
} else {
// it's enabled
}
});
这似乎不起作用...还有其他技巧可以检测到这种变化吗?
【问题讨论】:
-
if ( cb.prop("disabled") ) { ... },并且更改属性不会触发更改事件,使用JS更改值也不会。 -
您应该在更改状态时手动触发事件,并监听 that 事件
标签: javascript jquery events controls state