Copy codeThe Code is as follows:
Filter: <input type = "text" id = "sea"/>
& Lt; table width = "100%" id = "se" & gt;
<Thead>
<Tr> <th> </th> <th> name </th> <th> gender </th> <th> address </th> </tr>
</Thead>
<Tbody>
<Tr class = "parent" id = "row_01"> <td colspan = "3"> class 1 </td> </tr>
<Tr class = "child_row_01"> <td> </td> <td> Grandpa </td> <td> male 10 </td> <td> Wuhan 1 </td> </tr>
<Tr class = "child_row_01"> <td> </td> <td> Grandpa </td> <td> male 9 </td> <td> Wuhan 2 </td> </tr>
<Tr class = "child_row_01"> <td> </td> <td> Grandpa </td> <td> male 8 </td> <td> Wuhan 3 </td> </tr>
<Tr class = "parent" id = "row_02"> <td colspan = "3"> class 2 </td> </tr>
<Tr class = "child_row_02"> <td> </td> <td> Grandpa </td> <td> male 7 </td> <td> Wuhan 4 </td> </tr>
<Tr class = "child_row_02"> <td> </td> <td> Grandpa </td> <td> male 6 </td> <td> Wuhan 5 </td> </tr>
<Tr class = "child_row_02"> <td> </td> <td> Grandpa </td> <td> male 5 </td> <td> Wuhan 6 </td> </tr>
<Tr class = "child_row_02"> <td> </td> <td> Grandpa </td> <td> male 4 </td> <td> Wuhan 7 </td> </tr>
<Tr class = "parent" id = "row_03"> <td colspan = "3"> class 3 </td> </tr>
<Tr class = "child_row_03"> <td> </td> <td> Grandpa </td> <td> male 3 </td> <td> Wuhan 8 </td> </tr>
<Tr class = "child_row_03"> <td> </td> <td> Grandpa </td> <td> male 2 </td> <td> Wuhan 9 </td> </tr>
<Tr class = "child_row_03"> <td> </td> <td> Grandpa </td> <td> male 1 </td> <td> Wuhan 10 </td> </tr>
</Tbody>
</Table>
<Script type = "text/javascript">
$ (Function (){
$ ("# Sea"). keyup (function (){
$ ("# Se tbody tr "). hide (). filter (": contains ('" + $ (this ). val () + "')"). show ();
}). Keyup ();
});
</Script>
Copy codeThe Code is as follows:
// Jquery table content filtering
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Script src = "../css/jquery-1.6.2.js"> </script>
<Script>
$ (Function (){
$ ('Tr. parent'). click (function (){
$ (This). toggleClass ("selected"). siblings ('. child _' + this. id). toggle ();
});
});
</Script>
<Style>
. Selected {background: red };
</Style>
<Title> Untitled Document </title>
</Head>
<Body>
<Table>
<Thead>
<Tr>
<Th> name </th>
<Th> age </th>
</Tr>
</Thead>
<Tbody>
<Tr class = "parent" id = "row_01">
<Td colspan = "2"> Ministry of Human Resources </td>
</Tr>
<Tr class = "child_row_01">
<Td> script </td>
<Td> 20 </td>
</Tr>
<Tr class = "child_row_01">
<Td> script </td>
<Td> 20 </td>
</Tr>
<Tr class = "child_row_01">
<Td> script </td>
<Td> 20 </td>
</Tr>
<Tr class = "parent" id = "row_02">
<Td colspan = "2"> Technology Department </td>
</Tr>
<Tr class = "child_row_02">
<Td> script </td>
<Td> 20 </td>
</Tr>
<Tr class = "child_row_02">
<Td> script </td>
<Td> 20 </td>
</Tr>
<Tr class = "child_row_02">
<Td> script </td>
<Td> 20 </td>
</Tr>
</Tbody>
</Table>
</Body>
</Html>