Agyan
adda
Run
Reset
Copy
jQuery Tutorial › jQuery Selectors › Selector playground
Back to tutorial
Code
Edit, then press Run or Ctrl+Enter
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script> <table border="1" cellpadding="6" style="border-collapse:collapse"> <tr><td>Asha</td><td>88</td></tr> <tr><td>Ravi</td><td>64</td></tr> <tr><td>Neha</td><td>91</td></tr> <tr><td>Aman</td><td>27</td></tr> </table> <p><label><input type="checkbox" checked> HTML</label> <label><input type="checkbox"> CSS</label> <label><input type="checkbox" checked> jQuery</label></p> <button id="stripe">Stripe rows</button> <button id="count">Count checked</button> <p id="out"></p> <script> $(function () { $('#stripe').click(function () { $('tr:even').css('background', '#eef4ff'); $('tr:last td').css('color', 'crimson'); }); $('#count').click(function () { $('#out').text($('input:checked').length + ' subjects selected'); }); }); </script>
Result