How to compare strings to jquery text()? I've tried this one but it will not work.
var str = 'hello';
var string = $(this).find("text").trim();
if(str == string)
{
string.css("visibility", "visible");
}
What's wrong with my code? Any idea please? thank you
If you want to use the text method you need to actually use it. Using find("text") would try fo find a <text> element inside the element, and there are no such elements.
Also, use the jQuery trim method as the string.trim method isn't available in all browsers. Apply the style to the element, not the string:
var str = 'hello';
var string = $.trim($(this).text());
if(str == string)
{
$(this).css("visibility", "visible");
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With