Here is my code for select unselect checkbox using Jquery:
<input id="demo_box_0" class="checkAll css-checkbox chk_box" type="checkbox" onclick="selectAll(this)" title="Select All"/>
other checkbox are :
<input id=\"demo_box_".$row->CompanyID."\" class=\"css-checkbox csscheck\" type=\"checkbox\" value=\"".trim($row->CompanyID)."\" />
As i have lengthy class name i am not getting expecting result
Here is my script :
$('.checkAll css-checkbox chk_box').click(function() {
if ($(this).is(':checked')) {
$('div input').attr('checked', true);
} else {
$('div input').attr('checked', false);
}
});
What is the mistake i am doing and how can i fix this ?
Update :
I even tried this
<script>
$(document).ready(function(){
$("#demo_box_0").click(function(){
//alert("just for check");
if(this.checked){
$('.checkAll css-checkbox chk_box').each(function(){
this.checked = true;
})
}else{
$('.checkAll css-checkbox chk_box').each(function(){
this.checked = false;
})
}
});
});
</script>