How do I search for a keyword and display a table containing that keyword instead of just the row containing that keyword use jquery?

Viewed 18

How do I search for a keyword and display a table containing that keyword instead of just the row containing that keyword use jquery? I used jquery but it didn't worked.Sorry for my bad english.For example this code:

 $(document).ready(function() {
   $('#myInput').on('keyup', function(event) {
      event.preventDefault();
      /* Act on the event */
      var tukhoa = $(this).val().toLowerCase();
      $('#mytable tr').filter(function() {
         $(this).toggle($(this).text().toLowerCase().indexOf(tukhoa)>-1);
      });
   });
});
 <input type="text" id="myInput" onkeyup="myFunction()" placeholder="Search for names.." title="Type in a name">
    <div class= "containter">
        <div class="row">
          <div class="col">
    <table class="mytable">
      <thead>
        <tr>
          <th scope="col">Number</th>
          <th scope="col">google link</th>
          <th scope="col">Random number</th>
          <th scope="col">Software</th>
        </tr>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script> 
      </thead>
      <tbody>
        <tr>
          <td>1</td>
          <td><a href=https://google.com>Google</a></td>
          <td>4</td>
          <td><a><b>1</b></a></td>
        </tr>
        <tr><td colspan=8  style="text-align:left">google tested 1</tr>
     </tbody>
    </table>
     </div>
          </div>
         </div>
         <div class= "containter">
        <div class="row">
          <div class="col">
    <table class="mytable">
      <thead>
        <tr>
          <th scope="col">Number</th>
          <th scope="col">google link</th>
          <th scope="col">Random number</th>
          <th scope="col">Software</th>
        </tr>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script> 
      </thead>
      <tbody>
        <tr>
          <td>1</td>
          <td><a href=https://google.com>Google</a></td>
          <td>4</td>
          <td><a><b>1</b></a></td>
        </tr>
         <tr><td colspan=8  style="text-align:left">google tested 2</tr>
     </tbody>
     </table>
How do I search for a keyword and display a table containing that keyword instead of just the row containing that keyword use jquery?

0 Answers
Related