侧边栏壁纸
博主头像
落叶人生博主等级

走进秋风,寻找秋天的落叶

  • 累计撰写 130562 篇文章
  • 累计创建 28 个标签
  • 累计收到 9 条评论
标签搜索

目 录CONTENT

文章目录

获取各种高度的方法

2024-05-07 星期二 / 0 评论 / 0 点赞 / 54 阅读 / 1273 字

做了个小实例,对比各种高度html代码:<button type="button" id="mybtn1">$(window).height()</button><button type="butto

做了个小实例,对比各种高度html代码:

<button type="button" id="mybtn1">$(window).height()</button><button type="button" id="mybtn2">$(document).height()</button><button type="button" id="mybtn3">$(document.body).height()</button>

js代码:

$(function(){	//打印$(window).height()的值	$("#mybtn1").on("click",function(event){		console.log("$(window).height():"+$(window).height());	});		//打印$(document).height()的值	$(document).on("click","#mybtn2",function(event){		console.log("$(document).height():"+$(document).height());	});	$("#mybtn3").on("click",function(event){		console.log("$(document.body).height():"+$(document.body).height());	});});

$(window).height(); //浏览器当前窗口可视区域高度

$(document).height(); //浏览器当前窗口文档的高度

$(document.body).height(); //浏览器当前窗口文档body的高度,内容越多,body高度越高,出现滚动条,数值会很大.

广告 广告

评论区