Toggle theme
문제를 잘 정의하는 것은 문제를 절반 해결한 것이다. - 2023.12
사용자 도구
Toggle theme
로그인
사이트 도구
검색
도구
문서 보기
이전 판
PDF로 내보내기
Fold/unfold all
역링크
최근 바뀜
미디어 관리자
사이트맵
로그인
>
최근 바뀜
미디어 관리자
사이트맵
현재 위치:
start
»
wiki
»
javascript
»
javascript_note
»
getattribute_method
wiki:javascript:javascript_note:getattribute_method
이 문서는 읽기 전용입니다. 원본을 볼 수는 있지만 바꿀 수는 없습니다. 문제가 있다고 생각하면 관리자에게 문의하세요.
======Javascript HTML DOM getAttribute() Method====== <WRAP left notice 80%> * description : Javascript HTML DOM textContent Property * author : 오션 * email : shlim@repia.com * lastupdate : 2021-06-08 </WRAP> <WRAP clear></WRAP> \\ =====The source of the article==== [[https://www.w3schools.com/jsref/met_element_getattribute.asp|Javascript HTML DOM getAttribute() Method]]\\ ====Example==== %%<h1>%% 요소의 클래스 속성 값을 가져옵니다.\\ <code javascript> <body> <h1 class="democlass">Hello World</h1> <p>Click the button to display the value of the class attribute of the h1 element.</p> <button onclick="myFunction()">Try it</button> <p id="demo"></p> <!-- democlass --> <script> function myFunction() { var x = document.getElementsByTagName('h1')[0].getAttribute('class'); document.getElementById('demo').innerHTML = x; } </script> </body> </code> =====Definition and Usage===== %%getAttribute()%% 메서드는 요소의 지정된 이름을 가진 속성 값을 반환합니다.\\ \\ **Tip:** 속성(attribute)을 %%Attr%% 객체로 반환하려면, %%getAttributeNode()%% 메서드를 사용하십시오.\\ =====Syntax===== <code javascript> element.getAttribute(attributename) </code> =====Parameter Values===== | Parameter ^ Type ^ Description ^ | attributename | String | 필수입니다. 값을 구하려는 속성의 이름 | =====Technical Details===== ^ Return Value ^ 문자열이며 특정 속성 값을 표시합니다. ^ | | **Note:** 속성이 존재하지 않을 경우, 반환 값은 null 또는 비어있는 문자열("") 입니다. | =====More Examples===== ====Example==== %%<a>%% 요소의 타겟(target) 속성 값을 가져옵니다.\\ <code javascript> <body> Read about the <a href="dom_obj_attributes.asp" id="myAnchor" target="_blank">Attr object</a> <p>Click the button to display the value of the target attribute of the link above.</p> <button onclick="myFunction()">Try it</button> <p id="demo"></p> <!-- _blank --> <script> function myFunction() { var x = document.getElementById('myAnchor').getAttribute('target'); document.getElementById('demo').innerHTML = x; } </script> </body> </code> ====Example==== %%<button>%% 요소의 온클릭 이벤트 속성(onclick event attribute)의 값을 가져옵니다.\\ <code javascript> <body> <p>Click the button to display the value of the onclick attribute of the button element.</p> <button id="myBtn" onclick="myFunction()">Try it</button> <p id="demo"></p> <!-- myFunction() --> <script> function myFunction() { var x = document.getElementById('myBtn').getAttribute('onclick'); document.getElementById('demo').innerHTML = x; } </script> </body> </code> {{tag>오션, Javascript HTML DOM getAttribute() Method}}
/volume1/web/dokuwiki/data/pages/wiki/javascript/javascript_note/getattribute_method.txt
· 마지막으로 수정됨: 2023/01/13 18:44 (바깥 편집)
문서 도구
문서 보기
이전 판
역링크
PDF로 내보내기
Fold/unfold all
맨 위로
작업 마치기
Close
완료 메시지
마치기