From the course: Learning App Building with Vanilla JavaScript

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

JavaScript events

JavaScript events - JavaScript Tutorial

From the course: Learning App Building with Vanilla JavaScript

Start my 1-month free trial

JavaScript events

- You can write all the down manipulation code you want but a web app doesn't become interactive without making it respond to events. To do that whether with a library of frame work or with vanilla java script we have to do three things. First we have to select the element that we want a user to be able to interact with. Second we have to specify what specific event should trigger the interaction. Like load for a page or click for a button. Finally we need to specify what should happen in response to the event. In jQuery we use a jQuery selector to select the element. Then we chain the on method passing the event name followed by either a function call or an anonymous function containing the code that should run. Vanilla Java script supports a few different ways to specify code to respond to an event on a specific element. The best way to do this is using an event listener. We start by using vanilla java script method to select the element we want to listen to. I find query selector…

Contents