How to create such a jQuery condition:
select all checkboxes on the page with the value (3, 8, 19) that are in the item variable, and hide the parent in which the checkboxes are located?

<ul> <li class="letter"><input type="checkbox" class="checkboxEmail" value="."$row[0]".'></li> <li class="letter"><input type="checkbox" class="checkboxEmail" value="."$row[0]".'></li> <li class="letter"><input type="checkbox" class="checkboxEmail" value="."$row[0]".'></li> ..... </ul> 

How to find a parent and hide, I figured out:

 $(".checkboxEmail").parent("letter").hide(); 
  • Not quite clear, but I think you can find it like this: $ ('form'). Find ('. CheckboxEmail [value = "3"]'). Parent ('li'). Parent ('ul'). Hide ( ); - webphp
  • var item = [1,2,3]; jQuery.each (item, function () {..... $ ("ul"). find (". checkboxEmail [value = '']"). parent ("li"). hide ();}); I do not understand how to add value to checkboxes in an array. - SergeyHashCode

2 answers 2

Something like this:

 item.forEach(function(number, index) { $('ul').find('.checkboxEmail[value="' + number +'"]').parent('li').parent('ul').hide(); }); 
  • Fine! Thank!!! - SergeyHashCode

First we select everything, then we hide the parent.

 $('.checkboxEmail[value="3"]').attr('selected','selected'); $('.checkboxEmail[value="8"]').attr('selected','selected'); $('.checkboxEmail[value="19"]').attr('selected','selected'); $('.checkboxEmail[value="3"]').parent('li').parent('ul:first').hide();