attr:属性值,代表着初始化的值
prop:可获得变动的值
select,check
eg:
<head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> <script src="jquery.min.js"></script> <script type="text/javascript"> function checkclick() { console.log($(":checkbox").prop("checked"));//为ture与false交替 console.log($(":checkbox").attr("checked"));//一直为checked } </script> </head> <body> <input type="checkbox" checked="checked" onclick="checkclick();"/> </body> </html>
时间: 2024-10-05 04:27:53