jQuery中innerHeight()方法用法實例
本文實例講述了jQuery中innerHeight()方法用法。分享給大家供大家參考。具體分析如下:
獲取第一個匹配元素內(nèi)部區(qū)域高度。
包括內(nèi)補白(padding)、不包括邊框border)。
也就是說內(nèi)部區(qū)域的寬度等于width和padding之和。
此方法對可見和隱藏元素均有效。
可以結(jié)合innerWidth()方法學習。
語法結(jié)構:
實例代碼:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="author" content="http://www.dbjr.com.cn/" />
<title>腳本之家</title>
<style type="text/css">
p{
background-color:green;
height:100px;
width:200px;
padding:10px;
border:5px solid red;
}
</style>
<script type="text/javascript" src="mytest/jQuery/jquery-1.8.3.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("button").click(function(){
$("p").text($("p").innerHeight())
});
});
</script>
</head>
<body>
<p>此處顯示innerHeight數(shù)值</p>
<button>點擊查看p的innerHeight</button>
</body>
</html>
上面的代碼可以將元素的內(nèi)部區(qū)域的高度寫入p元素中。
希望本文所述對大家的jQuery程序設計有所幫助。
相關文章

使用jquery局部刷新(jquery.load)從數(shù)據(jù)庫取出數(shù)據(jù)

Jquery實現(xiàn)列表(隔行換色,全選,鼠標滑過當前行)效果實例

jQuery實現(xiàn)可編輯表格并生成json結(jié)果(實例代碼)