【发布时间】:2012-01-03 13:29:45
【问题描述】:
我在一个组中有几个单选按钮,其中一个是:
<input type='radio' id='other' name='Group'></input>
<label for='other'>Other:</label>
我想这样做,以便在选中按钮时收到警报。当单选按钮变为未选中时,在被选中后(通过选择另一个按钮)我想收到不同的警报消息。
JQuery(这不起作用):
$('input:radio[id="other"]').change(
function(){
if ($(this).is(':checked')) {
alert("checked");
}
if ($(this).is(':notchecked')) {
alert("notchecked");
}
}
);
【问题讨论】:
-
用这段代码,它显示了什么?
-
@ianace 被选中的部分正在正确显示警报,但是当我“取消选中”按钮时,什么也没有发生
标签: jquery radio-button