JavaScript---Document Object Model (DOM)

Source: Internet
Author: User

DOM (Document Object model)

When an HTML page is loaded by the browser, the browser will create a corresponding one for all the tags on the entire HTML page.
object, the information we see on the browser is just the property information for those HTML objects. We just have to find
The corresponding object action object's properties, you can change what the browser currently displays.

The whole shape is like a tree, so it's called a document tree:

Each node in the document tree is called a node

1 <!DOCTYPE HTML Public "-//W3C//DTD XHTML 1.0 transitional//en" "http://www.w3.org/TR/xhtml1/DTD/ Xhtml1-transitional.dtd ">2 <HTMLxmlns= "http://www.w3.org/1999/xhtml">3 <Head>4 <Scripttype= "Text/javascript">5 6     functionCheckall (allnode) {7         //find all of the options8         varItems=Document.getelementsbyname ("Item");9         //find the object with the Select All buttonTen         //var allnode = Document.getelementsbyname ("All") [0]; One          for(varI= 0; I<items.length; I++){ A items[i].checked=allnode.checked; -         } -     } the      -      -     functiongetsum () { -         varItems=Document.getelementsbyname ("Item"); +         varsum= 0; -          for(varI= 0; I<items.length; I++){ +             if(items[i].checked) { A sum+=parseint (items[i].value); at             }     -         }     -         varSpannode=document.getElementById ("Sumid"); - spannode.innerhtml= ("&nbsp;&nbsp;&nbsp;&yen;"+sum). FontColor ("Green"); -     } -      in  -  to </Script> + <Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8" /> - <title>Untitled Document</title> the </Head> *  $ <Body>Panax Notoginseng     <Div>Product List</Div> -         <inputtype= "checkbox"name= "Item"value= " the" />Notebook computer 3000 USD<BR/> the         <inputtype= "checkbox"name= "Item"value= "1800"  />Notebook computer 1800 USD<BR/> +         <inputtype= "checkbox"name= "Item"value= "+"  />Notebook computer 300 USD<BR/> A         <inputtype= "checkbox"name= "Item"value= " the"  />Notebook computer 3000 USD<BR/> the         <inputtype= "checkbox"name= "Item"value= " the"  />Notebook computer 3000 USD<BR/> +         <inputtype= "checkbox"name= "Item"value= " the"  />Notebook computer 3000 USD<BR/> -         <inputtype= "checkbox"name= "All"onclick= "Checkall (this)"  />Select All<BR/> $         <inputtype= "button"value= "Total Amount:"onclick= "Getsum ()" /><spanID= "Sumid"></span> $ </Body> - </HTML>
View Code

JavaScript---Document Object Model (DOM)

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.