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>

Comments

Popular posts from this blog

Call PHP Function In JavaScript Using Ajax

List of Post Category Wise in wordpress