我在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/) –