XML DOM hasAttributes() 메서드
❮ 노드 객체
예시
다음 코드 조각은 " books.xml "을 xmlDoc에 로드하고 첫 번째 <book> 요소에 속성이 있는지 여부를 반환합니다.
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
myFunction(this);
}
};
xhttp.open("GET", "books.xml", true);
xhttp.send();
function myFunction(xml) {
var xmlDoc = xml.responseXML;
var x =
xmlDoc.getElementsByTagName('book')[0];
document.getElementById("demo").innerHTML =
x.hasAttributes();
}
산출:
true
정의 및 사용
hasAttributes() 메서드는 지정된 노드에 속성이 있으면 true 를 반환하고 그렇지 않으면 false 를 반환 합니다.
참고: 지정된 노드가 요소 노드가 아닌 경우 반환 값은 항상 false 입니다.
브라우저 지원
hasAttributes() 메서드는 모든 주요 브라우저에서 지원됩니다.
참고: Internet Explorer 9 및 이전 버전은 hasAttributes() 메서드를 지원하지 않습니다.
통사론
nodeObject.hasAttributes()
매개변수
없음.
반환 값
Type | Description |
---|---|
Boolean | Returns true if the specified node has any attributes, otherwise false |
기술적 세부 사항
DOM 버전 | 코어 레벨 2 노드 개체 |
---|
❮ 노드 객체