LearnFast.Ninja

jQuery select rows in table using selector contains text

Create new variable then insert to it all the tr elements that contains some text. At the working example we build a table with 3 rows. then we select the table by id name and select all the tr elements and select the elements that contain the text Traversing we save those rows to variable named Selected_Rows. We hide those Selected_Rows, but you can do whatever you want with the Selected_Rows.

Step 1: Create new variable then insert to it all the tr elements that contains some text. 
var Selected_Rows = $("#Users_Table tr:contains('Traversing')");
 
Working example: 

<html>

<head>

    <title>jQuery change css class name</title>

    <style type="text/css">

        #Users_Table {

            background-color: #ffffdd;

            border: 1px solid #c0c0c0;

        }

    </style>

    <script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.js"></script>

    <script type="text/javascript">

 

        $(document).ready(function () {

            var Selected_Rows = $("#Users_Table tr:contains('Traversing')");

            $(Selected_Rows).hide();

        });

 

    </script>

</head>

<body>

 

    <table id="Users_Table" style="position: relative;">

        <tr>

            <td>Selectors</td>

        </tr>

        <tr>

            <td>Properties</td>

        </tr>

        <tr>

            <td>Traversing</td>

        </tr>

    </table>

 

</body>

</html>

 
Result:


Tags

jquery

contains traversing