Jquery中.attr与.prop的区别
Posted 雪洗中关村
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Jquery中.attr与.prop的区别相关的知识,希望对你有一定的参考价值。
☆ http://www.jb51.net/article/114876.htm http://www.365mini.com/page/jquery-attr-vs-prop.htm https://www.cnblogs.com/smartXiang/p/5686800.html ☆ <!DOCTYPE html> https://www.cnblogs.com/ipetergo/p/6491321.html <html> <head> <meta charset="utf-8"> <title>菜鸟教程(runoob.com)</title> <script src="http://cdn.static.runoob.com/libs/jquery/1.10.2/jquery.min.js"> </script> <script> $(document).ready(function(){ $("button").click(function(){ $("#p1").html("attr(\'checked\'): " + $("input").attr(\'checked\') //checked + "<br>prop(\'checked\'): " + $("input").prop(\'checked\')); //true }); }); </script> </head> <body> <p><b>注意:</b>确认或取消选中该复选框,然后单击按钮刷新内容。</p> <button>查看attr() 和 prop() 的值</button> <br><br> <input id="check1" type="checkbox" checked="checked"> <label for="check1">Check me</label> <p id="p1"></p> </body> </html> ☆ $(\'input[id = planStartTime_add]\').attr("disabled", true); ☆ <div id="scan_div" class="editTraningClass content" >xxx</div> var $div_detail = $(\'div#scan_div\'); $div_detail.find(\'input\').attr(\'readOnly\', true); $div_detail.find(\'textarea\').attr(\'readOnly\', true); $div_detail.find("input[id=planStartTime_scan]")attr(\'disabled\', true);
http://www.365mini.com/page/jquery-prop.htm 【 jQuery.prop() 函数详解】;
以上是关于Jquery中.attr与.prop的区别的主要内容,如果未能解决你的问题,请参考以下文章