Find all elements on a page whose element ID contains a certain text using jQuery

Viewed 226987

I'm trying to find all elements on a page whose element ID contains a certain text. I'll then need to filter the found elements based on whether they are hidden or not. Any help is greatly appreciated.

4 Answers

This selects all DIVs with an ID containing 'foo' and that are visible

$("div:visible[id*='foo']");

Thanks to both of you. This worked perfectly for me.

$("input[type='text'][id*=" + strID + "]:visible").each(function() {
    this.value=strVal;
});
Related