JavaScript manipulating DOM objects

Source: Internet
Author: User

The DOM is the abbreviation for Document Object model, which is an API for document-based programming.

Using JavaScript to manipulate DOM objects is usually divided into three categories: 1.DOM CORE 2.html-dom and Css-dom.

This code involves 1 of the knowledge points. How to lock a node 2. Returns the formula used by the child node collection 3. How to traverse a node type

<! DOCTYPE html>
<title>4</title>
<script>
Window.onload=function () {
var Myul=document.getelementbyid ("box");//Lock element
Var lis=myul.childnodes;//returns a collection of child nodes
for (var i = 0; i < lis.length; i++) {
Create a loop, length of the child node collection
if (lis[i].nodetype==1) {
If the node type of each item that iterates through the collection of child nodes is an element node type (that is, nodetype==1)
alert (lis[i].innerhtml);
}
}

}

</script>


<body>
<ul id= "box" >
<li> Dinner </li>
<li> Sleep </li>
<li> dozen Peas </li>

</ul>
</body>

The knowledge points involved in this code are: How to create a label and how to add content to a new tag that you add

JavaScript operates the code for the Dom Action node property:

The knowledge points involved are: 1 gets the formula for the property value and the formula that sets the property value

JavaScript Operations DOM Delete and replace node code

Code to manipulate the node style:

Above reference

JavaScript manipulating DOM objects

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.