문제

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?

올바른 솔루션이 없습니다

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top