質問

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