国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 語言 > JavaScript > 正文

jQuery獲得包含margin的outerWidth和outerHeight的方法

2024-05-06 16:17:37
字體:
來源:轉載
供稿:網友

這篇文章主要介紹了jQuery獲得包含margin的outerWidth和outerHeight的方法,涉及jQuery中outerWidth及outerHeight方法的使用技巧,具有一定參考借鑒價值,需要的朋友可以參考下

本文實例講述了jQuery獲得包含margin的outerWidth和outerHeight的方法。分享給大家供大家參考。具體如下:

 

 
  1. <!DOCTYPE html> 
  2. <html> 
  3. <head> 
  4. <script src="js/jquery.min.js"> 
  5. </script> 
  6. <script> 
  7. $(document).ready(function(){ 
  8. $("button").click(function(){ 
  9. var txt=""
  10. txt+="Width of div: " + $("#div1").width() + "</br>"; 
  11. txt+="Height of div: " + $("#div1").height() + "</br>"; 
  12. txt+="Outer width of div (margin included): " + $("#div1").outerWidth(true) + "</br>"; 
  13. txt+="Outer height of div (margin included): " + $("#div1").outerHeight(true); 
  14. $("#div1").html(txt); 
  15. }); 
  16. }); 
  17. </script> 
  18. </head> 
  19. <body> 
  20. <div id="div1" style="height:100px;width:300px;padding:10px;margin:3px;border:1px solid blue;background-color:lightblue;"> 
  21. </div> 
  22. <br> 
  23. <button>Display dimensions of div</button> 
  24. <p>outerWidth(true) - returns the width of an element (includes padding, border, and margin).</p> 
  25. <p>outerHeight(true) - returns the height of an element (includes padding, border, and margin).</p> 
  26. </body> 
  27. </html> 

希望本文所述對大家的jQuery程序設計有所幫助。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表

圖片精選

主站蜘蛛池模板: 屯门区| 成武县| 乌鲁木齐市| 湘潭县| 兴隆县| 宽甸| 招远市| 定州市| 龙门县| 乌拉特中旗| 辽阳市| 鹤壁市| 当涂县| 衡东县| 安徽省| 西青区| 无极县| 桂东县| 东辽县| 石柱| 阿坝县| 灌云县| 华亭县| 新昌县| 赤峰市| 筠连县| 绥化市| 浦县| 当雄县| 新竹县| 盱眙县| 古蔺县| 道孚县| 遂昌县| 新营市| 连城县| 宁强县| 和顺县| 久治县| 和顺县| 澄江县|