Here is how to find the HTML element by the text it contains.
<body>
  <div>John Resig</div>
  <div>George Martin</div>
  <div>Malcom John Sinclair</div>
  <div>J. Ohn</div>

  <script>
    $( "div:contains('John')" ).css( "text-decoration", "underline" );
  </script>

</body>
The above code will find the HTML element i.e. div in our case, with text John, and add underline to it.

Reference:

Tags
Submitted by ychaugule on