Skip to content

Instantly share code, notes, and snippets.

@precious-ming
Created September 20, 2014 06:49
Show Gist options
  • Save precious-ming/b7c9f35ca0b257d4e950 to your computer and use it in GitHub Desktop.
Save precious-ming/b7c9f35ca0b257d4e950 to your computer and use it in GitHub Desktop.
jQuery-选中checkbox按钮可用
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<div>
<button id="commit" disabled>提交</button>
<input id="checkboxId" type="checkbox" />选中后提交按钮可用
</div>
<script src="http://cdn.bootcss.com/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).on("change","#checkboxId",function(){
if ($('#checkboxId').is(':checked')) {
$("#commit").attr({"disabled":false});
}else{
$("#commit").attr({"disabled":true});
}
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment