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
- PythonProgramming
- Java
- javascript
- 가입
- 보험
- python
- 파이썬
- 교보생명
- 심장질환
- 문자열
- 코딩
- 교보
- 인출수수료
- 프로그래밍
- 웹개발
- 중도인출
- 추가납입
- jQuery
- 사망
- Vue.js
- 수수료
- 프론트엔드
- 급성심근경색증
- 뇌출혈
- 특약
- 보험료
- 납입
- 리스트
- 변환
- 자바스크립트
Archives
- Today
- Total
SeouliteLab
jQuery의 .removeProp() 메서드: 속성 제거하기 본문
jQuery의 .removeProp() 메서드는 선택한 요소의 프로퍼티(property)를 제거합니다. 이 메서드는 주로 jQuery로 추가한 프로퍼티를 제거할 때 사용됩니다. 하지만 HTML 속성(attribute)를 제거하는 데에는 .removeAttr() 메서드를 사용해야 합니다.
예제 1: 프로퍼티 제거하기
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>jQuery .removeProp() 메서드 예제</title>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
$(document).ready(function(){
// 프로퍼티 제거하기 예제
$('#checkbox1').removeProp('checked');
});
</script>
</head>
<body>
<input type="checkbox" id="checkbox1" checked>
</body>
</html>
<!-- 출력 결과 -->
<!-- <input type="checkbox" id="checkbox1"> -->
예제 2: 다중 프로퍼티 제거하기
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>jQuery .removeProp() 메서드 예제</title>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
$(document).ready(function(){
// 다중 프로퍼티 제거하기 예제
$('#input2').removeProp('disabled autocomplete');
});
</script>
</head>
<body>
<input type="text" id="input2" disabled autocomplete="off">
</body>
</html>
<!-- 출력 결과 -->
<!-- <input type="text" id="input2"> -->
예제 3: 조건부로 프로퍼티 제거하기
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>jQuery .removeProp() 메서드 예제</title>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
$(document).ready(function(){
// 조건부로 프로퍼티 제거하기 예제
var condition = true;
if (condition) {
$('#checkbox3').removeProp('checked');
}
});
</script>
</head>
<body>
<input type="checkbox" id="checkbox3" checked>
</body>
</html>
<!-- 출력 결과 -->
<!-- <input type="checkbox" id="checkbox3"> -->
'프로그래밍' 카테고리의 다른 글
jQuery의 .val() 메서드: 입력 요소의 값 가져오기 및 설정하기 (0) | 2024.03.27 |
---|---|
jQuery의 .toggleClass() 메서드: 클래스 토글하기 (0) | 2024.03.27 |
jQuery의 .removeClass() 메서드: 클래스 제거하기 (0) | 2024.03.27 |
jQuery의 .removeAttr() 메서드: 속성 제거하기 (0) | 2024.03.27 |
jQuery의 .prop() 메서드: 속성 조작하기 (0) | 2024.03.27 |