how do i compare the two elements:
<a class="MenuSelected" href="c-4-kayaks-canoes.aspx">Kayaks & Canoes</a>
and this:
<div class=title>Kayaks & Canoes</div>
If it finds the text in div.title as the same then add css display:none
I am not sure what to try as its the text inside that i need comparing!
I cant hard code the string like in the example below.
$("div.title:contains('John')").css("display", "none");
or, more explicit but also more versatile (for example it allows to do case-insensitive comparisons):
You could do
$.trim()there as well, as @JaredFarrish suggests in the comments.The
:containsselector in comparison is case-sensitive and whitespace-sensitive, so it only selects exact matches.