手机
当前位置:查字典教程网 >编程开发 >Javascript教程 >jQuery获得包含margin的outerWidth和outerHeight的方法
jQuery获得包含margin的outerWidth和outerHeight的方法
摘要:本文实例讲述了jQuery获得包含margin的outerWidth和outerHeight的方法。分享给大家供大家参考。具体如下:$(do...

本文实例讲述了jQuery获得包含margin的outerWidth和outerHeight的方法。分享给大家供大家参考。具体如下:

<!DOCTYPE html> <html> <head> <script src="js/jquery.min.js"> </script> <script> $(document).ready(function(){ $("button").click(function(){ var txt=""; txt+="Width of div: " + $("#div1").width() + "</br>"; txt+="Height of div: " + $("#div1").height() + "</br>"; txt+="Outer width of div (margin included): " + $("#div1").outerWidth(true) + "</br>"; txt+="Outer height of div (margin included): " + $("#div1").outerHeight(true); $("#div1").html(txt); }); }); </script> </head> <body> <div id="div1"> </div> <br> <button>Display dimensions of div</button> <p>outerWidth(true) - returns the width of an element (includes padding, border, and margin).</p> <p>outerHeight(true) - returns the height of an element (includes padding, border, and margin).</p> </body> </html>

希望本文所述对大家的jQuery程序设计有所帮助。

【jQuery获得包含margin的outerWidth和outerHeight的方法】相关文章:

jQuery实现转动随机数抽奖效果的方法

浅谈jQuery中replace()方法

jQuery实现首页图片淡入淡出效果的方法

js兼容火狐获取图片宽和高的方法

jQuery实现控制文字内容溢出用省略号(…)表示的方法

jQuery实现dialog设置focus焦点的方法

jQuery实现不断闪烁文字的方法

jQuery仿gmail实现fixed布局的方法

js去字符串前后空格的实现方法

jQuery获取页面元素绝对与相对位置的方法

精品推荐
分类导航