STUDY/JavaScript
[JavaScript] 속성값 제어 Element.setAttribute()
bottlesun
2022. 11. 27. 02:17
Element.setAttribute()
지정된 요소의 속성 값을 설정한다. 속성이 이미 있는 경우 값이 업데이트가 된다.
그렇지 않으면 지정된 이름과 값으로 새 속성이 추가된다.
사용 방법
Element.setAttribute("className", "클래스명");
Element.setAttribute("id", "아이디명");
Element.setAttribute("name", "이름");
Element.setAttribute("href", "#");
728x90