Frage

I want to hide a block if <li class="first last"> has the text 120V in it.

This is the code i wrote but the block is still showing.

    $(document).ready(function() {
   // check to see if the li tag with css classes .first .last has the text 120V in it 

   if ($(".first .last").text() == "120V"){

   //if true hide the sidebar-second
       $("#my-block").hide();
    }
   else {
   //if false show the sidebar second
        $("#my-block").show();
    }       

    });
});

Where did i go wrong?

Keine korrekte Lösung

Andere Tipps

You need:

$(".first.last").text()

instead of:

$(".first .last").text()

You don't need any space here since space indicate the descendant elements. So your current selector will select any descendant with class last inside any element with class first.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top