<html>
<body>
<input type="checkbox" id="checkbox">
<br>
<input type="button" id="button" value="Check">
<script type="text/javascript">
function alertTrue(){
alert('checked');
}
function alertFalse(){
alert('unchecked');
}
var cb = document.getElementById('checkbox'),
bt = document.getElementById('button');
bt.onclick = function() {
if ( cb.checked ) {
alertTrue();
} else {
alertFalse();
}
}
</script>
</body>
</html>
|