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= (" ¥"+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)