日期:2014-05-17 浏览次数:23437 次
$('#checkbox').click(function(){ var checked = $('input:checked').val(); if(checked){ //do something a=1; }else{ //do something a=2; } });
<input type="checkbox" id="checkbox"/> <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.4.4.min.js"></script> <script type="text/javascript"> $('#checkbox').click(function(){ var a; var checked = $('input:checked').val(); if(checked){ //do something a=1; }else{ //do something a=2; } alert(a); }); </script>