[Solved] Why is my JavaScript if condition not working?


use $.trim like bellow

$("ul > li > a").click(function() {
   var value = $(this)[0].innerText;
   console.log(value);
   if($.trim(value) == "Gallery") {
      console.log("a");
   } else {
      console.log("b");                  
   }
});

enter image description here

5

solved Why is my JavaScript if condition not working?