jQuery獲得包含margin的outerWidth和outerHeight的方法
本文實(shí)例講述了jQuery獲得包含margin的outerWidth和outerHeight的方法。分享給大家供大家參考。具體如下:
<!DOCTYPE html>
<html>
<head>
<script src="js/jquery.min.js">
</script>
<script>
$(document).ready(function(){
$("button").click(function(){
var txt="";
txt+="Width of div: " + $("#div1").width() + "</br>";
txt+="Height of div: " + $("#div1").height() + "</br>";
txt+="Outer width of div (margin included): " + $("#div1").outerWidth(true) + "</br>";
txt+="Outer height of div (margin included): " + $("#div1").outerHeight(true);
$("#div1").html(txt);
});
});
</script>
</head>
<body>
<div id="div1" style="height:100px;width:300px;padding:10px;margin:3px;border:1px solid blue;background-color:lightblue;">
</div>
<br>
<button>Display dimensions of div</button>
<p>outerWidth(true) - returns the width of an element (includes padding, border, and margin).</p>
<p>outerHeight(true) - returns the height of an element (includes padding, border, and margin).</p>
</body>
</html>
希望本文所述對(duì)大家的jQuery程序設(shè)計(jì)有所幫助。
相關(guān)文章
利用jQuery中的ajax分頁實(shí)現(xiàn)代碼
這篇文章主要介紹了利用jQuery中的ajax分頁實(shí)現(xiàn)代碼的相關(guān)資料,對(duì)ajax分頁感興趣的朋友可以參考一下2016-02-02
JQuery動(dòng)態(tài)添加和刪除表格行的方法
這篇文章主要介紹了JQuery動(dòng)態(tài)添加和刪除表格行的方法,實(shí)例分析了jQuery中動(dòng)態(tài)操作表格行的技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-03-03
jquery實(shí)現(xiàn)彈出窗口效果的實(shí)例代碼
這篇文章主要介紹了jquery實(shí)現(xiàn)彈出窗口效果的實(shí)例代碼。需要的朋友可以過來參考下,希望對(duì)大家有所幫助2013-11-11
jQuery操作input type=radio的實(shí)現(xiàn)代碼
jQuery操作input type=radio的實(shí)現(xiàn)代碼,需要的朋友可以參考下2012-06-06
六款幫助你實(shí)現(xiàn)驚艷視差滾動(dòng)效果的jQuery插件
視差(Parallax)是指從不同的點(diǎn)看一個(gè)物體時(shí)形成的視覺差異,這個(gè)名詞是源自希臘文的παράλλαξις (parallaxis),意思是改變2012-09-09
jquery如何把參數(shù)列嚴(yán)格轉(zhuǎn)換成數(shù)組實(shí)現(xiàn)思路
某參數(shù)的列只有一個(gè)參數(shù),那么each是失敗,如何保證pp嚴(yán)格是數(shù)組呢,很簡單var a=[pp];這一句就行了,感興趣的朋友可以參考下哈,希望可以幫助到你2013-04-04
jQuery實(shí)現(xiàn)帶有上下控制按鈕的簡單多行滾屏效果代碼
這篇文章主要介紹了jQuery實(shí)現(xiàn)帶有上下控制按鈕的簡單多行滾屏效果代碼,涉及jquery鼠標(biāo)事件控制頁面翻頁滾動(dòng)效果的相關(guān)實(shí)現(xiàn)技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-09-09

