I am testing the following JS conditional in my console however it is returning "undefined" when it should be executing a logging to console. Can someone please explain why the following doesn't work? I can individually test jQuery("li.category652 a").text() and it returns "Signage" but I just can't get it to work in an if statement in console.
if (jQuery("li.category652 a").text() === "Signage") {
console.log("success");
}
else {
console.log("fail");
}
I can copy and paste that code into the console of any webpage that isn't the one I'm working on locally and you will get "fail" because the DOM element jQuery is looking for doesn't exist. If I do it on the webpage with that DOM element then all I get is "undefined" and no success or fail message.
That specific jQuery reference is unique to a local site I am working on but the above conditional can be treated as if it said this:
if ("Signage" === "Signage") {
console.log("success");
}
else {
console.log("fail");
}