复制代码 代码如下:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>获取页面宽度</title>
<script src="/UploadFiles/2021-04-02/jquery.min.js"> <script type="text/javascript">
$.format = function (source, params) {
if (arguments.length == 1)
return function () {
var args = $.makeArray(arguments);
args.unshift(source);
return $.format.apply(this, args);
};
if (arguments.length > 2 && params.constructor != Array) {
params = $.makeArray(arguments).slice(1);
}
if (params.constructor != Array) {
params = [params];
}
$.each(params, function (i, n) {
source = source.replace(new RegExp("\\{" + i + "\\}", "g"), n);
});
return source;
};
/*------------以上是字符串format函数----------------*/
$(document).ready(function () {
$("button").click(function () {
var d=$("#div1");
var txt = "";
txt += $.format("width(): {0}</br>", d.width());
txt += $.format("height(): {0}</br>", d.height());
txt += $.format("Inner Width: {0}</br>", d.innerWidth());
txt += $.format("Inner Height: {0}</br>", d.innerHeight());
txt += $.format("Outer Width: {0}</br>", d.outerWidth());
txt += $.format("Outer Height: {0}</br>", d.outerHeight());
txt += $.format("outerWidth(true): {0}</br>", d.outerWidth(true));
txt += $.format("outerHeight(true): {0}</br>", d.outerHeight(true));
txt += $.format("HTML文档宽度: {0}</br>", $(document).width());
txt += $.format("HTML文档高度: {0}</br>", $(document).height());
txt += $.format("浏览器视口宽度: {0}</br>", $(window).width());
txt += $.format("浏览器视口高度: {0}</br>", $(window).height());
$("#div1").html(txt);
});
});
</script>
</head>
<body>
<div id="div1" style="height:auto;width:300px;padding:10px;margin:3px;border:1px solid blue;background-color:lightblue;"></div>
<br/>
<button>显示当前各种尺寸</button>
<p><a href="http://4welove.taobao.com" target="_blank">手机话费、Q币、游戏充值</a></p>
<p>width() - 返回元素的宽度。</p>
<p>height() - 返回元素的高度。</p>
<p>innerWidth() 方法返回元素的宽度(包括内边距)。 </p>
<p>innerHeight() 方法返回元素的高度(包括内边距)。 </p>
<p>outerWidth() 方法返回元素的宽度(包括内边距和边框)。 </p>
<p>outerHeight() 方法返回元素的高度(包括内边距和边框)。 </p>
<p>outerWidth(true) 方法返回元素的宽度(包括内边距、边框和外边距)。 </p>
<p>outerHeight(true) 方法返回元素的高度(包括内边距、边框和外边距)。 </p>
<p>返回文档(HTML 文档)$(document).height()的高度</p>
<p>返回窗口(浏览器视口)$(window).height()的高度</p>
</body>
</html>
JQuery,宽度,高度
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
更新日志
- 纪钧瀚《钢琴阅读时光 雨中书店聆听轻音乐》[FLAC/分轨][399.62MB]
- 证声音乐图书馆《走向自然 疗心爵士乐》[320K/MP3][87.4MB]
- 证声音乐图书馆《走向自然 疗心爵士乐》[FLAC/分轨][184.94MB]
- 陈慧娴.2018-Priscilla-Ism演唱会3CD(2024环球红馆40复刻系列)【环球】【WAV+CUE】
- 郑秀文.1999-我应该得到(国)【华纳】【WAV+CUE】
- 陈家慧.2011-钢琴酒吧2CD【龙吟唱片】【WAV+CUE】
- 证声音乐图书馆《雨季 蓝调吉他 Rainy Blues》[320K/MP3][45.01MB]
- 证声音乐图书馆《雨季 蓝调吉他 Rainy Blues》[FLAC/分轨][109.13MB]
- 赞多《序章》[320K/MP3][45.54MB]
- 许巍.2004-每一刻都是崭新的【步升大风】【WAV+CUE】
- 群星.2024-四方馆影视原声带【韶愔音乐】【FLAC分轨】
- 陈雷.1997-安锁咧【金圆唱片】【WAV+CUE】
- 关淑怡.2013-MY.FAVORITE.SK.3CD【环球】【WAV+CUE】
- Sweety.2006-花言乔语【丰华】【WAV+CUE】
- 李恕权.2003-回·20年全精选2CD【SONY】【WAV+CUE】