HTML DOMTokenList remove() 메서드
- 이전 페이지 length
- 다음 페이지 replace()
- 上一层으로 돌아가기 HTML DOMTokenList
정의와 사용법
remove() 메서드는 DOMTokenList에서 하나(또는 여러 개)의 토큰을 제거합니다.
인스턴스
예제 1
"myStyle" 클래스를 요소에서 제거:
const list = element.classList; list.remove("myStyle");
예제 2
요소에 "myStyle" 클래스 추가:
const list = element.classList; list.add("myStyle");
예제 3
"myStyle"의 열림/닫힘을 전환합니다:
const list = element.classList; list.toggle("myStyle");
예제 4
요소에서 여러 개의 클래스를 제거합니다:
element.classList.remove("myStyle", "anotherClass", "thirdClass");
예제 5
요소의 클래스 이름 수를 얻으세요:
let numb = element.classList.length;
예제 6
요소가 "myStyle" 클래스를 가지고 있습니까?
let x = element.classList.contains("myStyle");
예제 7
요소가 "myStyle" 클래스를 가지고 있다면, "anotherClass"를 제거합니다。
if (element.classList.contains("mystyle")) { element.classList.remove("anotherClass"); }
문법
domtokenlist.remove(token, ...)
파라미터
파라미터 | 설명 |
---|---|
token | 필수입니다. 목록에서 제거할 토큰(token)이 필요합니다. |
반환 값
없음。
브라우저 지원
domtokenlist.remove()는 DOM Level 4 (2015) 기능입니다.
모든 브라우저가 지원합니다:
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
지원 | 지원 | 지원 | 지원 | 지원 |
Internet Explorer 11( 및 이전 버전)는 domtokenlist.remove()를 지원하지 않습니다.
관련 페이지
- 이전 페이지 length
- 다음 페이지 replace()
- 上一层으로 돌아가기 HTML DOMTokenList