Study Notes on JavaScript advanced programming (8): some Dom Basics

Source: Internet
Author: User
Tags xml parser

Dom is the greatest innovation in web history after HTML first appeared on the Internet.
 
1.
XML preface: <? XML version = "1.0"?>
Followed by the preface, it is generally pi-processing command, in order to process the pageProgram(For example, XML Parser) provides additional information. The only format requirement is that the first question mark must be followed by at least
There is a letter.
The most common pi is to specify a style sheet: <? XML-stylesheet type = "text/CSS" href = "style.css"?>
 
2.
Node Type
Alert (document. nodetype) // outputs "9"
 
Get and change the attribute value of a node
OBJ. getattribute (name );
OBJ. setattribute (attrname, newvalue );
 
Get all objects in document
Document. getelementsbytagname ("*"); // Mozilla
Document. All // IE 6
 
Common methods for creating nodes: browsers support these common methods;
Createdocumentfragment () // Add a File Fragment (or object set ). (Fragments can contain multiple objects)
Createelement ()
Createtextnode ()

Code:
<Head>
<SCRIPT type = "text/JavaScript">
Function createhello (){
VaR op = Document. createelement ("p ");
VaR optext = Document. createtextnode ("Hello World ");
Op. appendchild (optext );
Document. Body. appendchild (OP );
}
</SCRIPT>
</Head>
<Body onload = "createhello ()">
</Body>

Use the following methods
Appendchild (), removechild (), replaceChild (), insertbefore ()


Searcher nodeiterate and treewalker for deep traversal (see Book P159-P160)

 

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.