[英]Why isn't change event fired on html radio input after the tick is removed by ticking another radio in the same group?
The question says it all. 问题说明了一切。 If it's a feature and not a bug, is there a way to overcome it?
如果这是一项功能而不是错误,是否有办法解决? I found a good example elsewhere: http://jsfiddle.net/shaggyfrog/DUqYW/3/ In that example I would expect both alerts on click - one because the first radio looses it's tick and one because the other radio gets ticked.
我在其他地方找到了一个很好的示例: http : //jsfiddle.net/shaggyfrog/DUqYW/3/在该示例中,我希望单击时都发出警报-一个是因为第一个收音机松开了它的刻度,另一个是因为另一个收音机被打了。
You could bind the change event to the group rather than the individual elements, this when then fire whenever any of the radio buttons in that group are changed: 您可以将change事件绑定到组而不是单个元素,然后在更改该组中的任何单选按钮时触发:
$("[name='group1']").change(function () {
alert("foo");
});
$("[name='group1']").change(function () {
alert("bar");
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.