JavaScript

[DOM_Element] JS - setAttributeNode() 메서드 ★ - 속성노드 추가설정 (예: 클래스추가) (= setAttributeNode메서드 = 셋어트리뷰트노드메서드)

setAttributeNode() 예제

 

<style>

.hz {

  color: red;

}

</style>


<h1>홈짱닷컴 Homzzang.com</h1>


<button onclick="homzzang()">클릭</button>


<script>

function homzzang() {

  var attr = document.createAttribute("class");

  attr.value = "hz";

  var h = document.getElementsByTagName("H1")[0];

  h.setAttributeNode(attr); 

}

</script>

 

결과보기



분류 제목
Window_Object JS - window 객체 - 윈도우객체 (속성/메서드) 종류
API_Storage JS - Storage Object - 스토리지 객체 (※ 데이터 저장소)
Object JS - Object Constructor - 객체생성자종류 ★
Object JS - Object Prototypes - 객체프로토타입 (= 객체원형) ★
Object JS - object ECMAScript 5 - 객체혁명
DOM_Attribute JS - attr.isId -
DOM_Attribute JS - attr.name -
DOM_Attribute JS - attr.value -
DOM_Attribute JS - attr.specified -
DOM_Attribute JS - nodemap.getNamedItem() 메서드 -
DOM_Attribute JS - nodemap.item() 메서드 -
DOM_Attribute JS - nodemap.length -
DOM_Attribute JS - nodemap.removeNamedItem() 메서드 -
DOM_Attribute JS - nodemap.setNamedItem() 메서드 -
Window_Console JS - console.assert() 메서드 - 표현식이 FALSE인지 확인 (= 표현식 거짓 여부 체크 …
30/89
목록
 홈  PC버전 로그인 일본어
그누앞단언어
그누뒷단언어
그외코딩언어
그누보드
제작의뢰
Q&A
커뮤니티 3
웹유틸
회원센터
홈짱닷컴 PC버전 로그인