$('.list_body').each(function(){
var job_no = $(this).data('job_id');
if($.inArray(job_no, return_data)) {
$.noop();
}
else {
$(this).closest('div.list_body').remove();
}
});
.list_body data-attribute holds a job id reference.
What I need to do is remove the particular .list_body div if the job id is not included in the array return_data.
Not sure if the .each() function is the best practice here as currently it seems to get rid of a div even though the job id is in the array.
$.inArrayreturns-1if it's not in the array, so if thejob_idis the first in the array, the element is getting removed anyway. And if it's not in the array,-1is still going to be truthy.