You probably just need to go to the elements in question and check if their tagName begins with a given line ...
var myPrefix = "mycustom-thing-"; $("body").children().each(function() { if (this.tagName.substr(0, myPrefix.length).toLowerCase() == myPrefix) { console.log(this.innerHTML);
https://jsfiddle.net/svArtist/duLo2d0z/
EDITOR: Included for effectiveness:
If you can predict where the elements will be, you can, of course, indicate this circumstance. In my example, these elements were direct children of the body , so I could use .children() to get them. It will not go through lower levels.
Reduce the need for workarounds by:
Start at the lowest level ( $("#specific-id") , not $("body") )
If all elements are found as direct children of the container:
- Use
$.children() in the container to get only immediate children
Else
If you can say something about the containing context, filter this
For example $("#specific-id").find(".certain-container-class .child-class *")
source share