1 / 14

Document Object Model

Document Object Model. CSc 2320 Fall 2013. 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. In this chapter. Document Access.

julius
Télécharger la présentation

Document Object Model

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Document Object Model CSc 2320 Fall 2013 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? • Bummer! There is no native function for that! • No .getElementsByClassName() until you create it!

  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

More Related