-1

I have the following structure, what I want to achieve is that if the point class has the "black" attribute, the button does not appear. Someone who can help me please

     <div class="container" > 

         <div class="card" > 
           <div class="button" > button </div>
            <div class="colors" > 
             <div value="black" class="point"> </div>
             <div value="white" class="point"> </div>
            </div>
           </div>
         </div> 


        if ($('.point').attr("value") == "black") {
              $(".button").hide();
         }
Joukhar
  • 724
  • 1
  • 3
  • 18

1 Answers1

0

Select everything with the class point which has a specific attribute (in this case value="black"). Then find the sibling of the parent div with the class .button and hide it. No need for the if statement.

$('.point[value="black"]').parent().siblings(".button").hide();
joshnishikawa
  • 71
  • 1
  • 5