Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- python
- PythonProgramming
- 납입
- 심장질환
- 뇌출혈
- 교보생명
- 추가납입
- 특약
- Vue.js
- 웹개발
- 변환
- 교보
- javascript
- 중도인출
- 문자열
- jQuery
- 보험
- 프로그래밍
- 수수료
- 프론트엔드
- 급성심근경색증
- Java
- 리스트
- 코딩
- 파이썬
- 보험료
- 인출수수료
- 자바스크립트
- 사망
- 가입
Archives
- Today
- Total
SeouliteLab
jQuery의 .removeClass() 메서드: 클래스 제거하기 본문
jQuery의 .removeClass() 메서드는 선택한 요소에서 지정된 클래스를 제거합니다. 이를 통해 동적으로 요소의 클래스를 조작할 수 있습니다.
예제 1: 클래스 제거하기
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>jQuery .removeClass() 메서드 예제</title>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
$(document).ready(function(){
// 클래스 제거하기 예제
$('#element1').removeClass('active');
});
</script>
<style>
.active {
color: red;
}
</style>
</head>
<body>
<div id="element1" class="active">활성화된 요소</div>
</body>
</html>
<!-- 출력 결과 -->
<!-- <div id="element1">활성화된 요소</div> -->
예제 2: 여러 클래스 제거하기
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>jQuery .removeClass() 메서드 예제</title>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
$(document).ready(function(){
// 여러 클래스 제거하기 예제
$('#element2').removeClass('active highlight');
});
</script>
<style>
.active {
color: red;
}
.highlight {
background-color: yellow;
}
</style>
</head>
<body>
<div id="element2" class="active highlight">활성화된 요소</div>
</body>
</html>
<!-- 출력 결과 -->
<!-- <div id="element2">활성화된 요소</div> -->
예제 3: 조건부로 클래스 제거하기
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>jQuery .removeClass() 메서드 예제</title>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
$(document).ready(function(){
// 조건부로 클래스 제거하기 예제
var condition = true;
if (condition) {
$('#element3').removeClass('active');
}
});
</script>
<style>
.active {
color: red;
}
</style>
</head>
<body>
<div id="element3" class="active">활성화된 요소</div>
</body>
</html>
<!-- 출력 결과 -->
<!-- <div id="element3">활성화된 요소</div> -->
'프로그래밍' 카테고리의 다른 글
jQuery의 .toggleClass() 메서드: 클래스 토글하기 (0) | 2024.03.27 |
---|---|
jQuery의 .removeProp() 메서드: 속성 제거하기 (0) | 2024.03.27 |
jQuery의 .removeAttr() 메서드: 속성 제거하기 (0) | 2024.03.27 |
jQuery의 .prop() 메서드: 속성 조작하기 (0) | 2024.03.27 |
jQuery의 .html() 메서드: 요소의 HTML 내용 조작하기 (0) | 2024.03.27 |