How to get two different array checkbox value in Jquery?
For example i have 5 checkbox, 3 checkbox with name=a[] and 2 checkbox with name=b[], if i checked array 开发者_运维技巧a[] 3checkbox iam getting the same value for b[] checkbox even b[] checkbox not checked. please suggest...
For ur reference:
var selectedAItems = new Array();
$("input[@name='a[]']:checked").each(function() {
selectedAItems.push($(this).val());
});
var selectedBItems = new Array();
$("input[@name='b[]']:checked").each(function() {
selectedBItems.push($(this).val());
});
alert(selectedAItems);
alert(selectedBItems );
The syntax with @
in the selector is deprecated since version 1.1.4 of jQuery and has been removed since version 1.3.
Just remove the @
from your selectors and it should work as expected
$("input[@name='a[]']:checked")
↯
$("input[name='a[]']:checked")
✔
精彩评论