I have an array with the value -1, 1, 2, 3, 4 etc. Im using this code the see if the value of a checkbox is in the array:
jQuery("#checkbox-container").find("input[type=\'checkbox\']").each(function() {
var state = jQuery.inArray(this.value, targetarray)!=-1;
jQuery(this).prop("checked", state);
});
It works with all numbers except -1. It will select the checkbox with value 1 instead of -1. Why does it do that?
Aucun commentaire:
Enregistrer un commentaire