Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

check / unchecked a checkbox with jQuery

<html>
<head>
<title>jQuery check / uncheck a check box example</title>
 
<script type="text/javascript" src="jquery-1.3.2.min.js"></script>

</head>

<body>

<h1>jQuery check / uncheck a check box example</h1>

<script type="text/javascript">

  $(document).ready(function(){

    $("#isCheck").click(function () {
		
	alert($('input:checkbox[name=checkme]').is(':checked'));
			
    });
	
    $("#checkIt").click(function () {
		
	$('input:checkbox[name=checkme]').attr('checked',true);
			
    });
	
    $("#UnCheckIt").click(function () {
		
	$('input:checkbox[name=checkme]').attr('checked',false);
			
    });	
		
  });
</script>
</head><body>

<input type="checkbox" name="checkme">Check Me</input>

<br/>
<br/>
<br/>

<input type='button' value='Is Check' id='isCheck'>
<input type='button' value='Check It' id='checkIt'>
<input type='button' value='UnCheck It' id='UnCheckIt'>

</body>
</html>
Source by mkyong.com #
 
PREVIOUS NEXT
Tagged: #check #unchecked #checkbox #jQuery
ADD COMMENT
Topic
Name
2+4 =