Jquery中.attr與.prop的區別
阿新 • • 發佈:2018-05-16
time tran checkbox rtx rtt don www ado ID
☆ 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);
Jquery中.attr與.prop的區別