We will try to understand everything about events in this post.


Events is one of the most interesting and fun to work with concept in JavaScript.

Let me try to explain Events in layman terms. HTML document will be having whole bunch of tags with in it and when ever we want to associate some dynamism to any of the elements we will be using events.

Let me take a simple button

	<button class="slds-btn">Click me!!!</button>

If I were to provide some dynamic behaviour to the button am gonna add an Event Listener to it. A typical event listener is going to look like this.

const btn = document.querySelector('button');
btn.onclick = function() {
	console.log('HEY Salesforce Casts!!!');

Simple right ...

Now I can just remove the console.log() statement in the Event Listener and I can put some code to even make an Ajax callout.

In this post we will be looking at everything that we need to understand about events.