ㅁ $(this).hide() - 현재 HTML 요소를 숨김

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $("button").click(function(){
        $(this).hide();
    });
});
</script>
</head>
<body>
 
<h2>This is a heading</h2>
 
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
 
<button>Click me</button>
 
</body>
</html>
cs

결과 : 버튼이 삭제 된다.


ㅁ $("p.intro").hide - p태그의 intro 클래스의 요소 숨김

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $("button").click(function(){
        $("p.intro").hide();
    });
});
</script>
</head>
<body>
 
<h2>This is a heading</h2>
 
<p class="intro">This is a paragraph.</p>
<p>This is another paragraph.</p>
 
<button>Click me</button>
 
</body>
</html>
cs

결과 : This is a paragraph 삭제


ㅁ $("p:first") - p태그 첫 번째 요소 숨김

ㅁ $("[href]").hide - href 속성 요소 숨김

+ Recent posts