Jquery Select All,Select None,Select Invertion

Post a reply


In an effort to prevent automatic submissions, we require that you complete the following challenge.
Smilies
:icon_plusone: :like: :plusone: :gfb: :-D :) :( :-o 8O :? 8) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen: :angry: :baa: :biggrin:
View more smilies

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Jquery Select All,Select None,Select Invertion

Jquery Select All,Select None,Select Invertion

by mindphp » 25/09/2009 3:52 pm

Jquery Select All,Select None,Select Invertion

Code: Select all

<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready( function() {

// Select all
$("A[href='#select_all']").click( function() {
$("#" + $(this).attr('rel') + " INPUT[type='checkbox']").attr('checked', true);
return false;
});

// Select none
$("A[href='#select_none']").click( function() {
$("#" + $(this).attr('rel') + " INPUT[type='checkbox']").attr('checked', false);
return false;
});

// Invert selection
$("A[href='#invert_selection']").click( function() {
$("#" + $(this).attr('rel') + " INPUT[type='checkbox']").each( function() {
$(this).attr('checked', !$(this).attr('checked'));
});
return false;
});

});
</script>

<fieldset id="group_1">
<form>
<input type="checkbox" name="numbers" value="0" />
<input type="checkbox" name="numbers" value="1" />
<input type="checkbox" name="numbers" value="2" />
<input type="checkbox" name="numbers" value="3" />
<input type="checkbox" name="numbers" value="4" />
<input type="checkbox" name="numbers" value="5" />
<input type="checkbox" name="numbers" value="6" />
<input type="checkbox" name="numbers" value="7" />
<input type="checkbox" name="numbers" value="8" />
<input type="checkbox" name="numbers" value="9" />
</form>
</fieldset>.

<a rel="group_1" href="#select_all">Select All</a>
<a rel="group_1" href="#select_none">Select None</a>
<a rel="group_1" href="#invert_selection">Invert Selection</a>

Top