Jquery Select All,Select None,Select Invertion

รวมโค้ด AJAX Javascript Library jQuery Framework ต่างๆ ที่ใช้ คู่กับ php Script Ajax โค้ด Ajax Prototype UI แนะนำได้ที่นี่

Moderators: mindphp, ผู้ดูแลกระดาน

User avatar
mindphp
ผู้ดูแลระบบ MindPHP
ผู้ดูแลระบบ MindPHP
Posts: 22106
Joined: 22/09/2008 6:18 pm
Contact:

Jquery Select All,Select None,Select Invertion

Postby 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>
ติดตาม VDO: http://www.youtube.com/c/MindphpVideoman
ติดตาม FB: https://www.facebook.com/pages/MindphpC ... 9517401606
หมวดแชร์ความรู้: viewforum.php?f=29
รับอบรม และพัฒนาระบบ: viewtopic.php?f=6&t=2042

Return to “AJAX Javascript Library - jQuery”

Who is online

Users browsing this forum: No registered users and 1 guest