Document Object Model - DOM

dom tree

Node Object

nodes

 

DOM node object methods

DOM creating new nodes - createElement

 

DOM accessing nodes by id or tag

document.getElementById("id")  
element.getElementsByTagName("tag")  

DOM changing associated content or attributes

element = document.getElementById("div42"); //get the element first

element.innerHTML = "This text is <i>important</i>"; // set content

 

element.setAttribute... //change attribute appropriately

 

img.src="newImage.jpg"; // where grabbed image = img here alter the source of image to new image

 

DOM -redirecting to a new page

window.location.href = "newPage.html";

 

DOM - making invisibile/visible

 

 

DOM objects - beyond the node object

Every Javascript program can refer to the following global objects:

 

 

© Lynne Grewe