ArticleDirectory
Nodename, nodevalue, and nodetype contain information about nodes.
Record several common attributes in html dom:
Nodename, nodevalue, and nodetype contain information about nodes.
The nodename attribute contains the
... P > ilove youp>...var pra = document.getElementsByTagName (' P '); var items = pra[0].childnodes;console.log (items[0].nodevalue); // equivalent to console.log (Pra[0].innertext);Google Console test results:The difference between
This topic describes the nodeName, nodeValue, and nodeType attributes. this topic describes the nodeName, nodeValue, and nodeType attributes in detail.
NodeNameThe attribute contains the name of a node.The nodeName of the element node is the
The Code is as follows: {code ...} & amp; lt; br & amp; gt; In the content will be removed. You can retain html tags for any operations such as $ e-& amp; gt; innerHtml. 8.18 update: {code...} the code is as follows:
$html =
Test
There are several types of nodes in the DOM, common1. Documentation node (document, unique)2. Element nodes (those tags div,p, etc.)3. Attribute node (class,src this)4. Text node (text inserted inside p,div)Other..Where Element.nodevalue is the
First of all, there are three major nodes in the DOM, namely, element node, text node, attribute nodeELEMENT node: Forms the basis of the DOM. , is the root element in the document structure, representing the entire document, as well as ,,, and so
The NodeName property contains the name of a node.
The nodename of the element node is the label name
The nodename of the attribute node is the property name
The nodename of the text node is always #text
The nodename of the document node is
1. nodename attribute: name of the node.If the node is an element node, the name of the element is returned. In this case, it is equivalent to the tagname attribute. For example, AAAA : returns p.If it is an attribute node, nodename returns the
Html dom nodeName nodeValue, nodenamenodevalue
In javascript, we generally need to do this to obtain the title label and text.Var obj = document. getElementsById ("id1 ");Obj. nodeName; // obtain the tag name.Obj. nodeValue; // IE returns null.
It
today when using Childrennodes to operate the DOM, encountered a problem, carefully check the relevant API, record:
NodeName
The NodeName property contains the name of a node. The nodeName of the element node is the label name attribute node
Suppose we already have a DOM object whose content is as follows:Content
In JavaScript, we generally need to do this to obtain the title label and text.VaR Title = Dom. getelementsbytagname ("title ");Alert (title [0]. nodename); // obtain
1.innerHTMLThe written label is parsed into an elementobox.innerhtml = "123";Return all content including tagsConsole.log (obox.innerhtml);2.outerHTMLSet/modify content, including its own elementsWill parse the label3.innerTextLabels written are not
Phpxml operation class (custom)
/**
Php xml operations
Link: http://bbs.it-home.org
*/
Class requirelog
{
Protected static $ requirelog;
// Get ready for xml, if xml is not
I. Element Node // test element node, output node name, node type, and node value varliElementsdocument. getElementsByTagName (& quot; li & quot;); for (vari0; I & lt; liElements. length; I ++) {alert (liElements [I]. nodeName);
I. Element nodes
//
Objective
The function of Dom is to turn a Web page into a JavaScript object, so that you can use JavaScript to do a variety of things (such as add and delete content). The browser parses the HTML document into a series of nodes based on the DOM
0x01The DOM is the interface of the JavaScript Operation Web page, all called the Document Object model. Its role is to convert the Web page into a JavaScript object, so that you can use JavaScript to do various things (such as adding and deleting
Step-by-Step learning of php xml operations: XML concepts, DOMDocument objects, loading xml, reading and traversing nodes and attributes, modifying attribute nodes, adding element attributes, and deleting attribute nodes, learn the above to operate
Step-by-step learning of php xml operations: XML concepts, DOMDocument objects, loading xml, reading and traversing nodes and attributes, modifying attribute nodes, adding element attributes, and deleting attribute nodes, learn the above to operate
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.