dimanche 12 avril 2020

Simple if statment is not working in Jquery

This is my Js code:

    $("li").click(function() {
      console.log($(this).css("color"));
      if ($(this).css("color") === "rgb(128,128,128)") {
        console.log("grey");
      } else {
        $(this).css({
          color: "grey",
          textDecoration: "Line-through"
        });
      }
    });
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<ul>
<li>click me</li>
</ul>

Aucun commentaire:

Enregistrer un commentaire