帶示例的 jQuery innerHeight()
jQuery 中的 innerHeight() 方法用於返回內部高度。它包括填充,但忽略邊框和邊距。
語法
語法如下 -
$(selector).innerHeight()
示例
現在,讓我們看一個示例來實現 jQuery innerHeight() 方法 -
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
document.getElementById("demo").innerHTML = "<br>Inner Height of DIV = " + $("div").innerHeight()
});
});
</script>
</head>
<body>
<h2>Demo Box</h2>
<div style="height:150px;width:450px;padding:10px;margin:2px;background-color:green;"></div><br>
<button>Inner Height of div</button>
<p id="demo"></p>
</body>
</html>輸出
這會生成以下輸出 -

單擊按鈕以獲取內部高度 -

廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP