please submit an ASCII file with at least 5 JavaScript instr
please submit an ASCII file with at least 5 JavaScript instructions that give evidence of an acquaintance with the DOM and methods that interface with the DOM ( I have the DOM but i dont know how to upload it here, please help)
Solution
DOM Model : It is an Application programming interface for HTML and XML documents. It defines the structure of document and the way it is manipulated and accessed.
Javascrip can change HTML elements in page, content of HTML in page, CSS style of HTML elements.It can remove/add HTML elements and there are various functions available for the same. Javascript uses DOM model to find some element , to handle events on document and many more tasks can be done with help of javascript.
Here are few functions that are directly connected to DOM model and uses DOM model to perform various tasks.
Function used to traverse DOM :
getElementById():
This function retrieve a specific html element based on the element\'s Id. we pass element id as argument and it will return HTML component with that Id. This interprets structure of HTML document and then returns the proper element with given Id. programmatically possible to walk a DOM and get any element with help if this function.
There are many functions used to manipulate DOM
innerHTML : we can change content of any HTML with help of this instruction.
e.g : we want to put image in span with id id1.
javascript : document.getElementById(\'id1\').innerHTML = \'<img src=\"image1.gif\">\';
removeChild and parentNode:
removeChild : This can be used to remove child element of some element.
parentNode : returns parent element.
e.g : remove image with id image1.
javascript :
var s= document.getElementById(\'image1\');
 s.parentNode.removeChild(s);
Javascript can be used to handle events in DOM. There are many functions to do it.
onClick:
it can be used to handle any click event. the function will be performed after click event occurs on document.
eg. on click of button make background black.
javascript :
document.getElementById(\'id1\').onclick = function() {
   this.style.background = black ;
 };
few other examples :
-onChange
-createElement
-setAttribute
-getAttribute
-window.onLoad
-window.scrollTo..
We can say that javascript can be used for :
- accessing DOM
-manipulating DOM
-handling events on DOM
and many more like asynchronous data transfer and provide asynchronous communication with server.


