There is a selector in jQuery – :contains
Example:
str = 'test';
blocked_div = $(".mydiv:contains("+str+")");
blocked_div.find('img').hide();
...
<a href="http://example.com">test</a>
...
As I understand it’s search for a “test” text inside a “.mydiv” element.
But now i need to find a link “http://example.com” inside a “.mydiv” element, and :contains dont work in this situation. Can you recommend a solution to do this ?
Did you mean:
You can also use
*=or^=filters to find links which contain specified text anywhere or at start of string respectively.For your
strvariable, you can modify it like: