Presentation is loading. Please wait.

Presentation is loading. Please wait.

Document Object Model CSc 2320 Fall 2014 Disclaimer: All words, pictures are adopted from “Simple JavaScript”by Kevin Yank and Cameron Adams and also from.

Similar presentations


Presentation on theme: "Document Object Model CSc 2320 Fall 2014 Disclaimer: All words, pictures are adopted from “Simple JavaScript”by Kevin Yank and Cameron Adams and also from."— Presentation transcript:

1 Document Object Model CSc 2320 Fall 2014 Disclaimer: All words, pictures are adopted from “Simple JavaScript”by Kevin Yank and Cameron Adams and also from W3schools. Edited by Guoliang Liu, Only for Course CSc2320 at GSU CS Department

2 In this chapter Document Access

3 The Document Object Model The DOM(Mapping your html)

4 The Document Object Model Each element in html: ◦ A node in DOM tree. The complete DOM tree

5 The Document Object Model How to handle the attributes of a node? ◦ Make them child nodes. ◦ Call attribute nodes.

6 The Document Object Model Access the nodes you want ◦ First step: identify the nodes By Id ◦ In CSS In JavaScript

7 The Document Object Model Access the nodes you want By tag names ◦ In CSS ◦ In JavaScript

8 The Document Object Model Access the child nodes from your variable Access the nodes by class names? ◦ document.getElementsByClassName()

9 The Document Object Model Find parent node ◦ Use attribute “parentNode”; Find children nodes

10 The Document Object Model Find sibling nodes

11 The Document Object Model Get attribute ◦ Use “getAttribute()” or attribute name ◦ E.g. ◦ or

12 The Document Object Model Set attribute ◦ Use “setAttribute()”.

13 The Document Object Model Change style ◦ Use “style” to get CSS rules. ◦ E.g.,

14 The Document Object Model JavaScript libraries ◦ Provide different ways to access nodes. ◦ JQuery  By id  By class ◦ Dojo  By id  By class


Download ppt "Document Object Model CSc 2320 Fall 2014 Disclaimer: All words, pictures are adopted from “Simple JavaScript”by Kevin Yank and Cameron Adams and also from."

Similar presentations


Ads by Google