首页 > Web开发 > 详细

Jquery中.attr与.prop的区别

时间:2018-05-16 10:21:28      阅读:201      评论:0      收藏:0      [点我收藏+]
☆    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的区别

原文:https://www.cnblogs.com/hahajava/p/9044411.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!