How get an element if its inner text matches a pattern in jquery?
问题 Consider a html like below, <div id="test"> {{ sometext }} </div> <span class="testing"> {{ asdknfsdf }} </span> I want to get all the elements whose inner text matches {{ <sometext> }} in jquery. I tried the below code, but I could not get the elements properly. What am I missing here? var elements = []; $('*:contains("{{ .* }}")').each(function(){ elements.push(this); }); 回答1: Several things: 1) "Could not get the elements properly" isn't terribly descriptive. Are you getting no results?