JavaScriptのNodeインターフェース
1319 ワード
nodeName String , ;
nodeValue String , ;
nodeType Number ;
ownerDocument Document ;
firstChild Node childNodes ;
lastChild Node childNodes ;
childNodes NodeList ;
previousSibling Node ; , NULL;
nextSibling Node ; , NULL;
hasChildNodes() Boolean childNodes , ;
Attributes NamedNodeMap attr , Element ;
appendChild node childNodes ;
removeChild node;
replaceChild(newnode,oldnode) node, oldnode newnode;
insertBefore(newnode,refnode) childNodes refnode newnode;
:
getNamedItem(name): nodeName name ;
removeNamedItem(name): nodeName name ;
setNamedItem(node): node , nodeName ;
item(pos): NodeList , pos ;
example:
<p style="color:red" id="p1">hello world</p>
var sid=op.attributes.getNameItem("id").nodeValue; var sid=op.attributes.getNameItem(1).nodeValue;
var sid=op.getAttribute("id");
op.setAttribute("id","newid");
:
var op=document.create_rElement("p");
var otext=document.create_rTextNode("hello.");
op.appendChild(otext);
document.body.appendChild(op);
:
document.body.removeChile(op);