replace( ) 메서드
안의 속성을 할당 되어진것을 원하는 속성값으로 교체해주는 메서드이다.
<p> <p>
var test = document.querySelector('p')[0]
test.classList;
test.classList.add('happy');
test.classList.replace('happy','fun'); // happy -> fun 으로 변경
반응형
'javascript' 카테고리의 다른 글
함수 선언식, 표현식 차이 : 호이스팅 (0) | 2024.03.04 |
---|---|
setAttribute, getAttribute, removeAttribute 가 뭐야? 차이점 속성값변경, 삭제, 접근 (0) | 2024.02.29 |
concat( ), spread 연산자 배열 합치기는 어떻게해? (0) | 2024.02.29 |
localstorge , setItem , getItem , removeItem, stringify , parse 가뭐야 사용법 (0) | 2024.02.28 |
split( ) , replace ( ) 키값 불러온 후 쓸모없는 문자및 숫자 제거 (0) | 2024.02.26 |