Assuming I have this:
<div id="elementId">bla bla bla some text bla bla</div>
I want to check if this div text contains 'some text', then return true, otherwise return false, how to do that?
Assuming I have this:
<div id="elementId">bla bla bla some text bla bla</div>
I want to check if this div text contains 'some text', then return true, otherwise return false, how to do that?
You can use the :contains() selector and check the .length to see if it matched anything, like this:
return $("#elementId:contains('some text')").length > 0;
$() and .text() native JS methods? :contains() calls the same thing underneath..innerText won't work in Firefox :) quirksmode.org/dom/w3c_html.html#t04.innerText anyway, so yeah jQuery helps there for sure. As much as I love jQuery, sometimes I feel that it overlaps onto features that should be left alone. This kind of overlapping is what IMO contributes to people thinking that jQuery is a language, when really it's just a framework.