私のexist_id
配列の値がnull
の場合、if
の条件が成り立ちます。配列はJavaScriptのif文では機能しません
val = this.value
$(document).ready(function() {
$('.all_id_checkbox').click(function() {
var a = this.checked;
if (a == true) {
exist_id = new Array();
exist_id = <?php echo json_encode($exist); ?>;
val = parseInt(this.value);
if (jQuery.inArray(val, exist_id)) {
exist_error.push(val);
} else { }
}
});
});
'$のexist'の値は何ですか? PHPが出力された後のあなたの実際のJSコードは何ですか?私は 'exist_id'がオブジェクトであると推測します。したがって、' $ .inArray'は無効です。 –
'$(document).ready(function(){ $( '。all_id_checkbox')。 ){ VAR Aは= this.checked; VARヴァル=のparseInt(this.value)を、 IF(== TRUE){ するvar exist_error = [];? varがexist_id =; VAR new_array = Object.values(exist_id);他{}} }); (jQuery.inArray(ヴァル、new_array)){ exist_error.push(ヴァル)};場合 }) ; ' –