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:
  $rows.not($rowsMatch).addClass('is-hidden');
  
  // Show matching ones:
  $rowsMatch.removeClass('is-hidden');
}

$("#search").on("keyup", function() {
  searchHref(this.value);
});
.is-hidden { display: none; }
<input type=text id="search" placeholder="Search by URI">
<table>
  <thead>
    <tr>
      <th>id</th>
      <th>desc</th>
      <th>nvm</th>
    </tr>
  </thead>
  <tbody id="items">
    <tr>
      <td>1</td>
      <td><a href="https://www.google.com">Popular search engine</a></td>
      <td>google</td>
    </tr>
    <tr>
      <td>2</td>
      <td><a href="https://www.stackoverflow.com">Programming Q&amp;A</a></td>
      <td>stackoverflow</td>
    </tr>
    <tr>
      <td>3</td>
      <td><a href="https://area51.stackexchange.com/">Aliens</a></td>
      <td>area51</td>
    </tr>
  </tbody>
</table>

<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>

Problem :

I have the following html page…

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

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) {
                $row.hide();
            }
            else {
                $row.show();
            }
        }
    });
});

The problem is I need to change the

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

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….

Comments

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

By