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>

 

결과보기


방문 감사합니다. (즐겨찾기 등록: Ctrl + D)

분류 제목
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
목록
  • 채팅방
  • 필독
1. 채팅창 헤드에서 접속자 확인 2. 닉네임 클릭해 1:1 채팅 가능 3. 닉네임 클릭해 귓속말 가능 4. 닉네임 클릭해 호출하기 가능 5. 우하단 클릭해 환경 설정 가능 6. 의뢰글 작성 후 의뢰 상담 가능 7. 질문글 작성 후 질문 상담 가능 8. 채팅방에 개인정보 입력 금지 9. 채팅방에 광고 욕설 비방 금지
 홈  PC버전 로그인 일본어
웹디자인언어
서버관리언어
고급코딩언어
그누보드 1
제작의뢰
Q&A
커뮤니티 3
웹유틸
회원센터
홈짱 PC버전 로그인