Friday, February 10, 2012

how to know checkbox is checked in jquery

how to know checkbox is checked in javascript, Here we are provide a example similar to that 
 

Select Check box

code for this example :

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>

function selectcheckbox(x){
var cls = $(x).attr('class');

if($('.'+cls).attr('checked')){
alert('chek box is checked');
}
else { alert('check box is unchecked');}

}
</script>
<form action="" method="">
<input type="checkbox"  name="checkboxname" value="checkboxvalue" class="checkboxcls"  onclick="selectcheckbox(this)"/> Select Check box
</form>

No comments:

Post a Comment

If you Satisfied , Please Leave a comment