我试图找出已选中多少个复选框,但遇到了一些麻烦..
我的复选框全部命名为delete[]
。
var count = ($('#form_store_setup input[name=delete]:checked').length);
...这根本不起作用:
var count = ($('#form_store_setup input[name=delete[]]:checked').length);
最佳答案
您需要转义方括号。试试这个:
var count = $('#form_store_setup input[name=delete\\[\\]]:checked').length;
或者将属性值放在引号中:
var count = $('#form_store_setup input[name="delete[]"]:checked').length;
关于javascript - 获取按名称选中的复选框数量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23812040/