/*
ownerDocument 属性
返回当前根节点
*/
window.οnlοad=function () {
var odiv=document.getElementById(“div1”);
alert(odiv.ownerDocument==document);
alert(odiv.parentNode.nodeName);//body
}
/*parentNode(返回当前节点的父节点)
previousSibling()返回该节点的前一根同级节点
nextSibling属性*(返回该节点的后一个同级节点)*/
/*属性节点
attribute返回该节点的属性节点的集合
集合特点:
1、无顺序 2、不重复*/
window.onload=function () {
var odiv1=document.getElementById("div2");
alert(odiv.attributes);
//访问其中一个节点
alert(odiv.attributes.getNamedItem("id"));//object attribute
alert(odiv.attributes["id"]);
/*属性节点
nodeName nodeType nodeValue
属性名 类型2 值*/
alert(odiv.attributes["id"].nodeType);
alert(odiv.attributes["id"].nodeValue);
alert(odiv.attributes["id"].nodeName);
}
</script>