 <p>Since you want to get all the elements whose immediate text contains 'Total amount', the <code>:contains('')</code> selector won't help you as it will return all the elements in the upper hierarchy of the actual element.<br> Try this <strong>JQuery</strong> code:</p> <pre><code>$('body *').each(function() { if($(this).clone().children().remove().end().text().indexOf("Total amount") &gt; -1) { // $(this) has your desired text as it's immediate text, so use it here } }); </code></pre> <p><strong>JSFiddle:</strong> <a href="http://jsfiddle.net/y00d1n5u/1/" rel="nofollow">http://jsfiddle.net/y00d1n5u/1/</a><br> Above code iterates over all the elements inside the <code>body</code> tag, strips each element's children and searches the remaining text for the search string.</p>