使用jQuery侦听复选框的多个值
我有一个jQuery钩子,它监听一个名为使用jQuery侦听复选框的多个值,jquery,Jquery,我有一个jQuery钩子,它监听一个名为wantProdTy的复选框,该复选框的值为“Mobile”或“Broadband”。我该怎么写 值为“Mobile”的复选框: 编辑 接受的答复: $('input[type="checkbox"][name="wantProdTy"]').filter(function(){ return /(Mobile|Broadband)/i.test(this.value); }).change(function() {
wantProdTy
的复选框,该复选框的值为“Mobile”或“Broadband”。我该怎么写
值为“Mobile”的复选框:
编辑
接受的答复:
$('input[type="checkbox"][name="wantProdTy"]').filter(function(){
return /(Mobile|Broadband)/i.test(this.value);
}).change(function() {
<% // check that the checkbox is checked %>
if($(this).is(':checked')) {
<% // check that mobile or broadband has not reached the maximum limit %>
maximumServiceLimitListener();
}
});
$('input[type=“checkbox”][name=“wantproddy”]')。过滤器(函数(){
返回/(移动|宽带)/i.test(该值);
}).change(函数(){
如果($(this).is(':checked')){
maximumServiceLimitListener();
}
});
您可以使用过滤器
:
$('input[name=wantProdTy]').filter(function(){
return /(mobile|broadband)/i.test(this.value);
});
将一个类放在一组复选框上,并倾听:
$(".myCheckboxClass").change(function(){
// do something
});
谢谢没有办法在选择器级别执行此操作吗?这是否意味着如果它不是移动或宽带,该功能将返回。否则它会继续吗?我知道了。谢谢你的帮助。
$(".myCheckboxClass").change(function(){
// do something
});