Forms and JavaScript: Inspect the value of an item

In this unit I’ll show you how to use JavaScript to interact with a form.

Let’s start with the simple form we defined in the Introduction to Forms unit:

  <input type="text" name="city" />

Using the DOM API and in particular querySelector, we can get the value typed into this input field:


This is often used along with events.

Lessons in this unit:

0: Introduction
1: ▶︎ Inspect the value of an item
2: Listen to events on input fields
3: Intercepting a form submit event using JavaScript
Want to learn more? Check out our courses