A pair of broad, flat rocks in a tidal beach pool

Selectors in JavaScript have much the same purpose as CSS selectors, allowing the developer to gain access to and target elements on the page.

While some of these selectors have been around since the very first incarnation of JavaScript, and are familiar to most developers, others, such as the powerful Selector API, remain largely under-appreciated.

Like most reading lists on this site, this remains a work in progress, with more arcane selection methods to be added in due course.

Prerequisites: JavaScript Fundamentals

Estimated time: 30 minutes

  1. getElementsByTagName
  2. getElementById
  3. getElementsByClassName
  4. querySelector & querySelectorAll

Photograph by Chris Gin, used under a Creative Commons license

Enjoy this piece? I invite you to follow me at twitter.com/dudleystorey to learn more.