jquery 07 addClass()와 removeClass()메소드
프론트엔드/Jquery2021. 3. 18. 00:10
HTML5
CSS3
자바스크립트
제이쿼리
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
$(document).ready(function(){
$("button.addd").click(function() {
$("h1.a, h2.b, p.c").addClass("blue");
$("div.d").addClass("important");
});
$("button.removee").click(function() {
$("h1.a,h2.b,p.c").removeClass("blue");
$("div.d").removeClass("important");
});
});
</script>
<style>
.important{
font-weight : bold;
font-size: xy-large;
}
.blue{
color: blue;
}
</style>
</head>
<body>
<h1 class="a">HTML5</h1>
<h2 class="b">CSS3</h2>
<P class="c">자바스크립트</P>
<div class="d">제이쿼리</div>
<button class="addd">CSS 적용</button>
<button class="removee">CSS 적용 해제</button>
</body>
</html>'프론트엔드 > Jquery' 카테고리의 다른 글
| jquery 10 박스를 클릭하면 박스 크기와 색상이 변경 (0) | 2021.03.18 |
|---|---|
| jquery 09 css() 메소드 (0) | 2021.03.18 |
| jquery 06 mousedown()와 mouseup() 메소드 (0) | 2021.03.17 |
| jquery 05 mouseenter()와 mouseleave() 메소드 (0) | 2021.03.17 |
| jquery 04 mouseenter() 메소드 (0) | 2021.03.17 |
댓글()
초보개발자의 성장블로그




