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
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
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
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
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
//
I. Understanding DOM with different levels of nodes1. Node hierarchyTake the following HTML as an example:sample pagehello world!This simple HTML document can be represented as a hierarchical structure.The document node is the root node of each
The previous article introduced how javascript accesses nodes.
This article describes how JavaScript operates nodes (including adding, deleting, modifying, and querying nodes ).
Based on the previous introduction, we know that the XML document
Php Chinese Network (www.php.cn) provides the most comprehensive basic tutorial on programming technology, introducing HTML, CSS, Javascript, Python, Java, Ruby, C, PHP, basic knowledge of MySQL and other programming languages. At the same time,
/*Javascript Implementation of dom (basic)Author: shine*/Dom is a Document Object Model that defines methods and attributes for operating XML documents, but it is only a series of interfaces implemented by other languages, such as xerces in Java,
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.