在jQuery中width,innerWidth和outerWidth,height,innerHeight和outerHeight之间有什么区别 [英] What is difference between width, innerWidth and outerWidth, height, innerHeight and outerHeight in jQuery

查看:162
本文介绍了在jQuery中width,innerWidth和outerWidth,height,innerHeight和outerHeight之间有什么区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了一些例子来看看有什么区别,但它们在宽度和高度上显示相同的结果。

  ; html> 
< head>
< script type =text / javascriptsrc =jquery.js>< / script>
< script type =text / javascript>
$(document).ready(function(){
var div = $('。test');
var width = div.width(); // 200 px
var innerWidth = div.innerWidth(); // 200px
var outerWidth = div.outerWidth(); // 200px

var height = div.height(); // 150 px
var innerHeight = div.innerHeight(); // 150 px
var outerHeight = div.outerHeight(); // 150 px
});

< / script>
< style type =text / css>
.test
{
width:200px;
height:150px;
background:black;
}
< / style> ;,
< / head>
< body>
< div class =test>< / div>
< / body>
< / html>

在此示例中,您可以看到它们输出相同的结果。如果有人知道有什么区别,请给我适当的回答。



谢谢。

解决方案

您看到这些示例吗?看起来与您的问题类似。





jQuery:height,width,inner and outer


I wrote some example to see what is the difference, but they display me same results for width and height.

<html>
    <head>
        <script type="text/javascript" src="jquery.js"></script>
        <script type="text/javascript">
            $(document).ready(function(){
                var div = $('.test');
                var width = div.width(); // 200 px
                var innerWidth = div.innerWidth(); // 200px
                var outerWidth = div.outerWidth(); // 200px

                var height = div.height(); // 150 px
                var innerHeight = div.innerHeight(); // 150 px
                var outerHeight = div.outerHeight(); // 150 px
            });

        </script>
        <style type="text/css">
            .test
            {
                width: 200px;
                height: 150px;
                background: black;
            }
        </style>
    </head>
    <body>
        <div class="test"></div>
    </body>
</html>

In this example you can see that they output same results. If anyone know what is the difference please show me appropriate answer.

Thanks.

解决方案

Did you see these examples? Looks similar to your question.

Working with widths and heights

jQuery - Dimensions

jQuery: height, width, inner and outer

这篇关于在jQuery中width,innerWidth和outerWidth,height,innerHeight和outerHeight之间有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆