cis 461 web development i
DESCRIPTION
CIS 461 Web Development I. HTML DOM part II Jongwook Woo, PhD [email protected] California State University, Los Angeles Computer Information System Department. Content. DOM Node Access DOM Events. DOM Node Access (Cont’d). You can access a node in three ways: - PowerPoint PPT PresentationTRANSCRIPT
Multihoming for Hosts on IPv6
CIS 461 Web Development I
HTML DOM part II
Jongwook Woo, [email protected]
California State University, Los AngelesComputer Information System Department
Computer Information SystemCalifornia State UniversityLos AngelesJongwook WooJongwook WooCSULAJongwook WooComputer Information SystemMulithoming for Hosts on IPv61ContentDOM Node AccessDOM Events
Jongwook WooCSULAJongwook WooComputer Information SystemMulithoming for Hosts on IPv62DOM Node Access (Contd)You can access a node in three ways:By using the getElementById() methodBy using the getElementsByTagName() methodBy navigating the node tree, using the node relationshipsThe getElementById() Methodreturns the element with the specified ID:Syntaxnode.getElementById("id");Exampledocument.getElementById("intro"); The example gets the element with id="intro":
Jongwook WooCSULAJongwook WooComputer Information SystemMulithoming for Hosts on IPv63DOM Node Access (Contd) getElementsByTagName() MethodThe getElementsByTagName() Methodreturns all elements with a specified tag name.Syntaxnode.getElementsByTagName("tagname");Example 1document.getElementsByTagName("p");The example returns a nodeList of all elements in the document:Example 2document.getElementById('main').getElementsByTagName("p");The example returns a nodeList of all elements that are descendants of the element with id="main":
Jongwook WooCSULAJongwook WooComputer Information SystemMulithoming for Hosts on IPv64DOM Node Access (Contd) getElementsByTagName() Methodreturns a node-list. That is, elementsA node-list is an array of nodesExamplex=document.getElementsByTagName("p");The code selects all nodes in a node-list:The nodes can be accessed by index number. To access the second you can write:y=x[1];Note:The index starts at 0.
Jongwook WooCSULAJongwook WooComputer Information SystemMulithoming for Hosts on IPv65DOM Node Access (Contd) getElementsByTagName() Method
Hello World! The DOM is very useful! x=document.getElementsByTagName("p"); document.write("Text of second paragraph: " + x[1].innerHTML);
Display The DOM is very useful!For x[0].innerHTML Display Hello World!For x[2].innerHTML Display Nothing out of bounce error
Jongwook WooCSULAJongwook WooComputer Information SystemMulithoming for Hosts on IPv66DOM Node Access (Contd) getElementsByTagName() MethodDOM Node List LengthThe length property defines the number of nodes in a node-list.You can loop through a node-list by using the length property:Examplex=document.getElementsByTagName("p");
for (i=0;i