jQuery has and contain

The :has() filter finds elements that contain another selector. For example, say you want to find all rows in a table that has a link then you can use


The following example highlights all the rows of a table that contains a link

<script type="text/javascript" src="jquery-1.8.0.min.js"></script>
  $("tr:has(a)").css("background-color", "pink");


<h1>List of Cars </h1>

<table border=1>
      <td>S No.</td>
      <td>Reference Designer</td>
      <td>2 </td>
      <td><a href ="http://google.com"> google </a></td>
      <td>3 </td>

You may like to try this example here.

:contains() is another filter that finds elements that contain specific text. For example, to find every link that says "here" you can create a jQuery object like this:


As an exercise you may want to modify the example so that it makes use of contains .