• 코드:
​x
 
1
<!DOCTYPE html>
2
<html lang="ko">
3
​
4
<head>
5
    <meta charset="UTF-8">
6
    <title>jQuery Element Dimension</title>
7
    <script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
8
    <style>
9
        #divBox { 
10
            width: 200px;
11
            height: 100px;
12
            background-color: orange;
13
        }
14
    </style>
15
    <script>
16
        $(function() {
17
            $("button").on("click", function() {
18
                $("#divBox").width("400");  // id가 "divBox"인 요소의 너비를 설정함.
19
                $("#divBox").height("200"); // id가 "divBox"인 요소의 높이를 설정함.
20
            });
21
        });
22
    </script>
23
</head>
24
​
25
<body>
26
​
27
    <h1>요소의 크기 변경</h1>
28
    <div id="divBox">
29
        <p id="text"></p>
30
    </div>
31
    <br>
32
    <button>요소의 크기 변경</button>
33
    
34
</body>
35
​
36
</html>