• 코드:
​x
 
1
<!DOCTYPE html>
2
<html lang="ko">
3
​
4
<head>
5
    <meta charset="UTF-8">
6
    <title>jQuery Effects</title>
7
    <script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
8
    <script>
9
        $(function() {
10
            $("#showBtn").on("click", function() {
11
                $("#text").show();  // id가 "text"인 요소를 나타나게 함.
12
            });
13
            $("#hideBtn").on("click", function() {
14
                $("#text").hide();  // id가 "text"인 요소를 숨김.
15
            });
16
        });
17
    </script>
18
</head>
19
​
20
<body>
21
​
22
    <h1>요소의 표시와 숨김</h1>
23
    <button id="showBtn">요소 표시하기!</button>
24
    <button id="hideBtn">요소 숨기기!</button>
25
    <p>CSS의 display 속성값이 none으로 설정되기 때문에 웹 페이지의 레이아웃에서 아예 사라져 버려요!</p>
26
    <p id="text">이 단락을 숨기거나 나타나게 할 거에요!</p>
27
    
28
</body>
29
​
30
</html>