/ Published in: jQuery

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<div class="options"> <ul> <li><a href="#" class="select-all">Select All</a></li> <li><a href="#" class="reset-all">Reset All</a></li> </ul> <input type="checkbox" id="option1" /><label for="option1">Option 1</label> <input type="checkbox" id="option2" /><label for="option2">Option 2</label> <input type="checkbox" id="option3" /><label for="option3">Option 3</label> <input type="checkbox" id="option4" /><label for="option4">Option 4</label> </div> $('.select-all').live('click', function(){ $(this).closest('.options').find('input[type=checkbox]').attr('checked', true); return false; }); $('.reset-all').live('click', function(){ $(this).closest('.options').find('input[type=checkbox]').attr('checked', false); return false; });
URL: http://eisabainyo.net/weblog/2010/09/01/10-useful-jquery-snippets/
Comments
