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.

谢谢。

4 个解决方案

#1


213

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

你看到这些例子了吗?看起来和你的问题很相似。

Working with widths and heights

使用宽度和高度

jQuery - Dimensions

jQuery -维

jQuery: height, width, inner and outer

jQuery:高、宽、内、外

更多相关文章

  1. 最简单jquery.ajax+php例子(对话框显示文本框输入内容),以小见大
  2. SprngMVC整合jquery的json 最简单的例子 一看就明白
  3. 模态的jQuery动态高度宽度
  4. jquery对json数据进行增删改查的例子
  5. 当侧面物品具有不同宽度时,保持中间物品居中
  6. HTML DIV百分比宽度奇奇怪怪的间距产生了?
  7. 另一个div内的任意宽度的中心div
  8. 当给出%宽度时,表的主体减少了Head的col 1空间的总空间
  9. 宽度切换jQuery中的Animate在FireFox中不起作用? [重复]

随机推荐

  1. Golang 可以写游戏吗?
  2. Go 语言和 Java 比较?
  3. Golang 能不能打包为 dll ?
  4. golang可以写网站吗
  5. Golang 免费的吗?
  6. 区块链实战-Hyperledger Fabric(一) 10分钟
  7. Golang 哪个 Web 框架好用?
  8. golang可以做些什么?
  9. Golang 是面向对象还是面向过程?
  10. golang吉祥物是啥?