admin管理员组文章数量:1287775
I'm trying to limit the number of checkboxes that can be checked within a form, but am getting the following error:
Uncaught Error: Syntax error, unrecognized expression: input:checkbox[name=ninja_forms_field_57[terms]]
Here is the Javascript that I'm using:
// Main Category
var $checkboxes_to_limit2 = $("#taxonomy_47").find("input:checkbox[name=ninja_forms_field_47[terms]]");
$checkboxes_to_limit2.live("change", function() {
if($checkboxes_to_limit2.filter(":checked").length >= 3) {
$checkboxes_to_limit2.not(":checked").attr("disabled","disabled");
}
else {
$checkboxes_to_limit2.removeAttr("disabled");
}
});
I'm trying to limit the number of checkboxes that can be checked within a form, but am getting the following error:
Uncaught Error: Syntax error, unrecognized expression: input:checkbox[name=ninja_forms_field_57[terms]]
Here is the Javascript that I'm using:
// Main Category
var $checkboxes_to_limit2 = $("#taxonomy_47").find("input:checkbox[name=ninja_forms_field_47[terms]]");
$checkboxes_to_limit2.live("change", function() {
if($checkboxes_to_limit2.filter(":checked").length >= 3) {
$checkboxes_to_limit2.not(":checked").attr("disabled","disabled");
}
else {
$checkboxes_to_limit2.removeAttr("disabled");
}
});
Share
Improve this question
asked Oct 20, 2013 at 22:42
adsfadsf
591 gold badge1 silver badge7 bronze badges
2 Answers
Reset to default 8You need to treat the name attribute as a string, so
input:checkbox[name=ninja_forms_field_47[terms]]
should be
input:checkbox[name='ninja_forms_field_47[terms]']
You need some additional single quotes:
var $checkboxes_to_limit2 =
$("#taxonomy_47").find("input:checkbox[name='ninja_forms_field_47[terms]']")
本文标签:
版权声明:本文标题:javascript - Uncaught Error: Syntax error, unrecognized expression: input:checkbox[name=ninja_forms_field_57[terms]] - Stack Ove 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741307561a2371460.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论