<html lang="ko">
<head>
<meta charset="UTF-8">
<title>jQuery Element Dimension</title>
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<style>
#divBox {
width: 300px;
height: 100px;
border: 2px solid orange;
}
</style>
<script>
$(function() {
$("button").on("click", function() {
var str = "이 div 요소의 ";
str += "너비는 " + $("#divBox").width() + "픽셀이고,<br>"; // id가 "divBox"인 요소의 너비를 반환함.
str += "높이는 " + $("#divBox").height() + "픽셀입니다." // id가 "divBox"인 요소의 높이를 반환함.
$("#text").html(str);
});
});
</script>
</head>
<body>
<h1>.width()와 .height() 메소드</h1>
<div id="divBox">
<p id="text"></p>
</div>
<br>
<button>요소의 크기 정보</button>
</body>
</html>