jQuery—一些常见方法(3)【width(),innerWidth(),outerWidth()】

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
    <script src="../../jq-practice/jq/jquery-2.2.1.min.js"></script>
    <script>
        $(function(){
            alert($('div').width());          //width
            alert($('div').innerWidth());      //width+padding
            alert($('div').outerWidth());      //width+padding+border
            alert($('div').outerWidth(true));     //width+padding+border+margin
            
        });
    </script>
</head>
<body>
<div style="width: 100px; height: 100px; padding: 10px; border: 4px solid red; margin: 5px; background: blue;" ></div>

</body>
</html>

 

posted @ 2016-08-18 18:40  MO蓦然回首  阅读(207)  评论(0编辑  收藏  举报