我在jq上遇到了问题!我试图通过它的名字检查复选框(它的数组)!所以一切都很好,直到我用if语句!在if语句中它的undefined!请看这里:在if语句中获取复选框值的未定义值?
$('#editSub').click(function(){
var $nameGiven=$('#editPlz').attr('name');
//here I got the values !
var values = new Array();
$.each($("input[name='status[]']:checked"), function() {
values.push($(this).val());
});
//this alert give forexample 102,103
alert(values);
if($nameGiven == 'status[]'){
//but here its undefined !!!!!! whyyy ?????
alert(values);
}
}
help me plz!在此先感谢
任何机会,你可以发布的HTML代码,其中包括你的'#editSub'element和你投入在JavaScript沙盒测试吗? – Lixus
[它的小提琴链接,检查这里的问题!](https://jsfiddle.net/s43k68xd/6/) –