modifying the content of a table if a row contains a specific string

Alternative way to achieve above is using eq(2) it will find element which is at 2 index starting from 0.

Demo Code:

$("tr:contains(test1)").find("td:eq(2)").html("test2");
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<table>
  <tr>
    <td>1</td>
    <td>test1 </td>
    <td>something </td>
  </tr>
  <tr>
    <td>2</td>
    <td>test1 </td>
    <td> something</td>
  </tr>
  <tr>
    <td>3</td>
    <td>test4 </td>
    <td> something</td>
  </tr>
</table>

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top