Booklet

author

Hack University

IT & Software

How to Access DOM Nodes of a Web Page

HOW TO ACCESS DOM NODES OF A WEB PAGE

DOM queries may return one element, or they may return a NodeList which is a collection of nodes.

  • getElementById('id')
    Selects an individual element given its id value. Returns a single elements node.
  • querySelector('css selector')
    Use CSS selector syntax that would select one or more elements. Returns only the first of the matching elements.
  • getElementsByClassName('class')
    Selects one or more elements given the value of their class attribute. Returns one or more elements (as a NodeList).
  • getElementsByTagName('tagName')
    Selects all elements on the page with the specified tag name. Returns one or more elements (as NodeList).
  • querySelectorAll('css selector')
    Uses CSS selector syntax to select one or more elements and returns all those that match. Returns one or more elements (as a NodeList).

More booklets by Hack University

More IT & Software booklets

Your recently viewed booklets

  • booklet-slide-images
  • booklet-slide-images
  • booklet-slide-images
  • booklet-slide-images
  • booklet-slide-images
  • booklet-slide-images
  • booklet-slide-images
  • booklet-slide-images
  • booklet-slide-images
  • booklet-slide-images
See all booklets