Working with Elements: an overview

Once you've found an element, JavaScript can read it and change it, from its text and CSS classes to which elements are on the page at all.

Apprentice · JavaScript · Updated

Key takeaways

  • Finding an element is the first step. Reading or changing it is the second.
  • JavaScript can read a value, change text, add or remove CSS classes, and create new elements and put them on the page.

Once we have found the element we are looking for, we can interact with it programmatically. For example, we could read the value of a textbox or select list; we could add or remove a CSS class from a div, or replace the text in a paragraph; or we could create a new DOM element and insert it as a child of a specific node.

So what

Find it, then change it: that two-step pattern is how a page answers the person using it, and the next two lessons show each kind of change.