javascript dom

16
JavaScript DOM

Upload: yoeung-vibol

Post on 29-Jul-2015

96 views

Category:

Technology


3 download

TRANSCRIPT

Page 1: Javascript DOM

JavaScriptDOM

Page 2: Javascript DOM

About Me

var orienter = { name: "Vibol YOEUNG", company: "Webridge Technologies", email: "[email protected]",};

Page 3: Javascript DOM

DOM Overview

DOM: Document Object Model - is a platform and language-neutral interface that allows programs and scripts to dynamically access and update the content, structure, and style of a document."

Page 4: Javascript DOM

DOM Overview

Page 5: Javascript DOM

Waiting for the HTMLDOM to Load

● HTML is parsed.● External scripts/style sheets are loaded.● Scripts are executed as they are parsed in the

document.● HTML DOM is fully constructed.● Images and external content are loaded.● The page is finished loading.

Page 6: Javascript DOM

Navigating the DOM

Page 7: Javascript DOM

Navigating the DOM

<html><head>

<title>JavaScript and DOM Interfaces </title><script>

function start() {myBody = document.getElementsByTagName("body")[0];myBodyElements = myBody.getElementsByTagName("p");myP = myBodyElements[1];

}</script></head><body onload="start()">

<p>hi</p><p>hello</p>

</body></html>

Page 8: Javascript DOM

Navigating the DOM

Page 9: Javascript DOM

Navigating the DOM(All node)

Page 10: Javascript DOM

Navigating the DOM

<p>

<strong>Hello</strong>

how are you doing?

</p>

Page 11: Javascript DOM

Navigating the DOM

Page 12: Javascript DOM

Creating Node

var textNode = document.createTextNode("world");var myNewPNode = document.createElement("p");

Page 13: Javascript DOM

Attaching, copying orremoving nodes

Page 14: Javascript DOM

Attaching, copying orremoving nodes

myP.appendChild(myTextNode);

Page 15: Javascript DOM

Node information

Page 16: Javascript DOM

Thanks for your time.