xxxxxxxxxx
<!DOCTYPE html>
<html>
<title>jQuery innerWidth()和innerHeight()示例 - 基础教程(div.cn)</title>
<head>
<script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("div").click(function(){
let w = $(this).innerWidth();
let h = $(this).innerHeight();
$(this).html("Inner width: " + w + "<br>" + "Inner height: " + h);
});
});
</script>
<style>
div {
width: 300px;
height: 100px;
margin: 5px;
padding: 10px;
border: 3px solid lightgreen;
background-color: rgba(144, 238, 144, .4);
}
</style>
</head>
<body>
<div>单击此DIV获取内部宽度/高度(包括内边距)</div>
</body>
</html>