Solution 1 :

Filter your rows by the child elements attribute [href*=""] containing *= a value.
Notice that this is not the best way to build Search functionality, since users most probably 1: never search URIs, 2: they will not understand how is the result related to their search query if the visible result has nowhere to be seen the term they searched for**.

But here you go anyways.

PS: the below code will also work if you have multiple HREF attributed elements in a single row!

const $rows = $("#items").find("tr"); // Collect all TBODY's TR

function searchHref(val) {
  val = val.trim(); // Trim it, you don't want spaces to account
  if (!val) return $rows.removeClass("is-hidden"); // Show all if empty search
  // Get rows which contain one or more [href] elements
  // containing the search value:
  const $rowsMatch = $rows.filter((i, TR) => $('[href*="'+ val +'"]', TR).length);
  // Hide all but the matching ones:
  // Show matching ones:

$("#search").on("keyup", function() {
.is-hidden { display: none; }
<input type=text id="search" placeholder="Search by URI">
  <tbody id="items">
      <td><a href="">Popular search engine</a></td>
      <td><a href="">Programming Q&amp;A</a></td>
      <td><a href="">Aliens</a></td>

<script src=""></script>

Problem :

I have the following html page…

<input type=text id="search">
<td><a href="">Some text...</a></td>

This code runs in a PHP loop

And I have the following jquery code already….

$("#search").on("keyup", function() {
    var value = $(this).val();

    $("table tr").each(function(index) {
        if (index !== 0) {

            $row = $(this);

            var id = $row.find("td:first").text();

            if (id.indexOf(value) !== 0) {
            else {

The problem is I need to change the


to the second td with hyperlink.

I thought it was simple

$row.find("td:nth-child(2) a").text();

But this doesn’t works… Also doesn’t works,

$row.find("td:eq(2) a:eq(0)").text();

I don’t know how to select the hyperlink text ( Some text … ) from the second td…

I need to search through all hyperlinks if a certain text is found….


Comment posted by Roko C. Buljan

SO basically you’re building a Search input that will search only for a specific text-value

Comment posted by Roko C. Buljan

Ps… if instead you use