首页 > 语言 > JavaScript > 正文

jQuery获得document和window对象宽度和高度的方法

2024-05-06 16:17:37
字体:
来源:转载
供稿:网友

这篇文章主要介绍了jQuery获得document和window对象宽度和高度的方法,涉及jQuery获取document和window对象属性的技巧,具有一定参考借鉴价值,需要的朋友可以参考下

本文实例讲述了jQuery获得document和window对象宽度和高度的方法。分享给大家供大家参考。具体如下:

 

 
  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+="Document width/height: " + $(document).width(); 
  11. txt+="x" + $(document).height() + "/n"; 
  12. txt+="Window width/height: " + $(window).width(); 
  13. txt+="x" + $(window).height(); 
  14. alert(txt); 
  15. }); 
  16. }); 
  17. </script> 
  18. </head> 
  19. <body> 
  20. <button>Display dimensions of document and window</button> 
  21. </body> 
  22. </html> 

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

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表

图片精选