Events in Web Page
Asynchronously handling events on a web page through JavaScript
Background
We have learned about DOM and its manipulation through JavaScript. We have yet to dynamically change DOM on a web page with listeners using JavaScript asynchronously. Let’s jump into the events on a web page! We can use asynchronous JavaScript to make dynamic changes and react to the events.
Introduction to events
Events are actions that occur on the browser or on a web page. JavaScript can listen to these actions to do certain tasks. Some events are:
- load: Event of loading the element on a web page
- click: Event when an element is clicked on a web page
- keypress: Event when a user presses a key
In JavaScript, we can leverage these events through the Event
object by adding listeners. This makes a more dynamic and interactive web page.
Get hands-on with 1200+ tech skills courses.