Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/linq/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用jQuery侦听复选框的多个值_Jquery - Fatal编程技术网

使用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() {

我有一个jQuery钩子,它监听一个名为
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
});