is的运用
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <title>判断是否被选中</title> </head> <input type="checkbox" id="cr" /> <label for="cr">点击关联复选框</label> <br /> <br /> <input type="button" value="注册" /> <body> <script type="text/javascript" src="jquery-1.11.1.min.js"></script> <script type="text/javascript"> $(function(){ var reg = $('input:nth-of-type(2)'); var cr = $('#cr'); reg.click(function(event) { if(cr.is(':checked')){ alert('完成注册'); }else{ alert('请勾选同意协议按钮'); } }); }) </script> </body> </html>