1 <!DOCTYPE HTML>2 <HTML>3 <Head>4 <MetaCharSet= "UTF-8">5 <title>The DOM object of JS</title>6 <Scripttype= "Text/javascript">7 //Dom:document Object Model Document objects8 /*9 documents: Hypertext document HTML, XMLTen object: Provides properties and methods One model: Manipulating Hypertext-tagged documents using properties and methods A You can use the JS DOM-provided object to manipulate the tagged document using the properties and methods of these objects - you need to encapsulate the tags, attributes, and text contents of HTML into objects. - */ the /* - There are three types of DOM models - DOM Level 1: Encapsulate an HTML document as an object - DOM Level 2: Add new features based on the 1, for example: Support for events and CSS styles + DOM Level 3: Support for some new features of XML 1.0 - */ + /* A parsing Process at Assigning a tree structure in memory based on the hierarchy of HTML requires that each part of the HTML be encapsulated as an object - Document: Entire HTML document - element: Tag Object - Property Object - Text Object - Node Nodes object: Is the parent object of these objects in */ - /* to Common Properties + all[] Provides access to all HTML elements in the document, FF does not support - forms[] Returns references to all form objects in the document the body provides direct access to <body> elements * Common Methods $ getElementById () returns a reference to the first object that owns the specified IDPanax Notoginseng Getelementsbyname () returns a collection of objects with the specified name - getElementsByTagName () returns a collection of objects with the specified label name the write () writes HTML code or JavaScript code to the document + */ A window.onload= function() { the varspans=document.getElementsByTagName ("span")[1]; + //For (var i = 0; i < spans.length; i++) - //{ $ //var span = spans[i]; $ document.write ("<br/>span:" +spans.innerhtml); - //} - } the </Script> - </Head>Wuyi <Body> the <BR/><BR/><BR/> - <span>AAAAA</span> Wu <span>bbbbb</span> - <span>Ccccc</span> About <span>Ddddd</span> $ </Body> - </HTML>
JavaScript base 15--js Dom Object