jQuery对HTML的页面尺寸操作

  1. width()和height()方法
    • 返回或设置元素的宽高(不包括内边距、边框、外边距)
1 $("button").click(function(){
2   "div 的宽度是: " + $("#div1").width() + "</br>";//不带值显示
3     "div 的高度是: " + $("#div1").height(20); //带值设置
4 });

用法下同

  1. innerWidth()和outerHeight()方法
    • 返回或设置元素的宽高(包括内边距)
  2. outerWidth()和outerHeight()方法
    • 返回或设置元素的宽高(包括内边距、边框)
    • outerWidth(ture)(包括内边距、边框、外边距)
  3. scrollTop()和scrollLeft()方法
    • 返回或设置滚动条被去的元素高度和宽度。
posted @ 2020-08-16 20:00  帅气巴巴  阅读(266)  评论(0编辑  收藏  举报