Search⌘ K

Solution: Move by a Certain Number

Explore how to control page elements dynamically by using JavaScript to respond to user input. This lesson guides you through adding event listeners, preventing default form submission, extracting numeric input, converting it properly, and updating a box's position on the screen.

Customizing behavior based on user input

Add the JavaScript code logic to move the box by user input (We've already added the HTML code for you). Instead of moving the box by a fixed amount, let the user type how many pixels they want the box to move.

Below are some hints to help you get started: ...