BootWiki教程网
源代码:
点击运行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>BootWiki 教程网</title> <script src="//cdn.staticfile.net/jquery/1.10.2/jquery.min.js"></script> <script> $(document).ready(function(){ $("button").click(function(){ $("#p1").html("attr('checked'): " + $("input").attr('checked') + "<br>prop('checked'): " + $("input").prop('checked')); }); }); </script> </head> <body> <p><b>注意:</b>确认或取消选中该复选框,然后单击按钮刷新内容。</p> <button>查看attr() 和 prop() 的值</button> <br><br> <input checked="checked" id="check1" type="checkbox"> <label for="check1">Check me</label> <p id="p1"></p> </body> </html>
运行结果