article

Saturday, February 23, 2013

Simple jquery Select All Checkbox

Simple jquery Select All Checkbox



<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<SCRIPT language="javascript">
$(function(){
// add multiple select / deselect functionality
$("#selectall").click(function () {
$('.item').attr('checked', this.checked);
});
// if all checkbox are selected, check the selectall checkbox and viceversa
$(".item").click(function(){
if($(".item").length == $(".item:checked").length) {
$("#selectall").attr("checked", "checked");
} else {
$("#selectall").removeAttr("checked");
}

});
});
</SCRIPT>
Select All Checkbox <input type="checkbox" id="selectall"/><br/>
<input type="checkbox" class="item" value="1"/>
Jquery<br/>
<input type="checkbox" class="item" value="2"/>
php mysql<br/>
<input type="checkbox" class="item" value="3"/>
Java<br/>

Related Post