Presentation is loading. Please wait.

Presentation is loading. Please wait.

Document Object Model www.mrsaem.com.

Similar presentations


Presentation on theme: "Document Object Model www.mrsaem.com."— Presentation transcript:

1 Document Object Model

2 Our scripts will be added to a page. Document Object Model

3 Both are Documents

4 Arrays are Objects Dates etc
In simple word individual pieces of information in a page will be an object.

5

6 Set of terms that we agree on

7 That discribe exactly how to interact with
So what do we agree upon That discribe exactly how to interact with

8

9

10

11

12

13 So how do we use JavaScript to Grab/hold one of these Nodes/Elements
Needs to be Unique So how do we use JavaScript to Grab/hold one of these Nodes/Elements

14 And if the Element that you are after and it has that unique ID
Grab it in JavaScript Using one of the most Imp Method of Document Object that is And if the Element that you are after and it has that unique ID

15 getElementById <html> <head> <title>getElementById example</title> <script> function changeColor(newColor) { var elem = document.getElementById("para1"); elem.style.color = newColor; } </script> </head> <body> <h1 id="para1">Some text here</h1> <form> <input type="button" onClick="changeColor('blue');" value="Turn to Blue"> <input type="button" onClick="changeColor('red');" value="Turn to Red"></form> </body> </html>

16 Remember that is case sensitive

17

18 What if I don’t have an ID on the Element Or I want is more than one element.

19

20 Makes an Array

21

22 TextBox Color function changecolor() { var rang=document.getElementById("mycolor2"). rang.style.backgroundColor='red'; }

23


Download ppt "Document Object Model www.mrsaem.com."

Similar presentations


Ads by Google