Searching $(....contains(...)) function for ID + class names
Assume I have a HTML code similar to:
- <div> ....
- <span id="myid2151511" class="myclass23462362">....foobar....</span>
- ....
- </div>
then I can search for the text string "foobar" and hide the innermost corresponding <div> element with the following jQuery code:
- $("div:contains('foobar')").eq(($("div:contains('foobar')").length) - 1).css("display", "none");
However this command does NOT work when I search for text patterns in id or class names. So the following does not work:
- $("div:contains('myid')").eq(($("div:contains('myid')").length) - 1).css("display", "none");
How do I have to code a jQuery statement to search for parts of an id or class name otherwise?
To simplify the question: forget about the css action for the innermost hierarchy level. Just give me a hint on how to search textually on ALL the stuff (including HTML code) inside a certain element.
Thank you
Peter