mardi 17 mai 2022

JS hide all elements with same class except one

I got multiple checkboxes and some of them are with same class, name and value. How can I hide them except one with JS or Jquery? Here is my code which is echoing multiple checkboxes (there is a loop before them)

 <input style="width: auto;" type="checkbox" name="<?php the_field('tiker'); ?>" value="<?php the_field('tiker'); ?>">
 <label for="scales"><?php the_field('tiker'); ?></label>

Examples of outputed inputs:

    <div style="margin-top: 5px;"> 
<input style="width: auto;" type="checkbox" name="SBER" value="SBER"> 
<label for="scales">SBER</label>
<input style="width: auto;" type="checkbox" name="SBER" value="SBER"> 
<label for="scales">SBER</label> 
<input style="width: auto;" type="checkbox" name="vtbr" value="vtbr"> 
<label for="scales">vtbr</label> 
<input style="width: auto;" type="checkbox" name="APL" value="APL"> 
<label for="scales">APL</label>
</div>



Aucun commentaire:

Enregistrer un commentaire