my goal is to check if any -data (data-id) on site have same value as one of elements in array but inArray always returns -1
<a href="#" data-id="2">
<a href="#" data-id="3">
<script>
var arrayObjects = <?php echo $json_array; ?>;
console.log(arrayObjects);
$("[data-id]").each(function(){
var data_id = $(this).data('id');
if(jQuery.inArray(data_id, arrayObjects) > -1) { // f
console.log(data_id);
console.log('found');
} else { // nf
console.log(data_id);
console.log('not found');
}
});
From my console:
["2", "3"]
3
not found
2
not found