tr odd Selects all odd rows of table – jQuery
$( “tr:odd” ) – selector is used to select the odd rows of the table.
tr odd Selects all odd rows of table with jQuery syntax
tr odd Selects all odd rows of table – jQuery Example
<!DOCTYPE html> <html> <head> <title>tr odd Selects all odd rows of table - jQuery Example</title> <script type="text/javascript" src="http://code.jquery.com/jquery-2.1.4.min.js"> </script> <script type="text/javascript"> $(document).ready(function(){ $("#demo").click(function(){ $("#myTable > tbody > tr:odd").css("background","yellow"); }); }); </script> </head> <body> <a href="javascript:void(0)" id="demo"> Click Me To Select Odd Rows </a><br><br> <table id='myTable'> <tbody> <tr><td>Jhohn</td><td>jhone@gmail.com</td><td>USA</td></tr> <tr><td>Kelly</td><td>kelly@gmail.com</td><td>USA</td></tr> <tr><td>Kamana</td><td>kamna@gmail.com</td><td>India</td></tr> <tr><td>Anay</td><td>anay@gmail.com</td><td>Canada</td></tr> <tr><td>AnaMy</td><td>amy@gmail.com</td><td>Canada</td></tr> <tr><td>Rummy</td><td>asd@gmail.com</td><td>Canada</td></tr> <tr><td>Jelly</td><td>y@gmail.com</td><td>Canada</td></tr> </tbody> </table> </body> </html> |
Note : Row Index starts from 0,1,2….
Advertisements