# Introduction to JavaScript events

javascript event එකක් කියන්නේ web browser එකේ වෙන action එකක්.javscript event වලට HTML elements වලට react කරන්න පුලවන්.

For example, when users click a button on a webpage, you may want to respond to this click event by displaying a dialog box. ඒ කිවේ user button කියන html elemet එක click කරාම dialog box එකක් display වෙලා event එකක් trigger වෙනවා.

### **Common Events**

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1699374355381/d9b83c38-a784-4218-a49d-bba44e8608c5.png align="left")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1699374373657/3cd7538a-3465-4b6c-9c06-31aadad9def4.png align="left")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1699374386159/75b4698d-b5bb-45b0-95a5-7f579ca7dda0.png align="center")

### **Ways Of Event Handling In JavaScript**

1. **Inline Event Handling**
    

මෙතනදී වෙන්නේ onclick, onsubmit වගේ html event වලට directly javascript embaded කරන එක.The example given below shows you how to do inline event handling

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1699434959582/97dc1de2-ff90-499f-9de1-86133a5058ef.png align="left")

2\. By using a separate function

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1699457553523/ba09d190-64ea-482b-a0ad-bd4c8f214105.png align="center")

3\. By using an event listener

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1699457703551/b89cdfec-c981-40d0-93ed-e3ef2129fcd6.png align="left")

In the next article, I am going to write about event flow in javscript.

if there is something that you cannot agree with or something that needs to be added, please let me know through a response (comment).

you can find more information from the following sources

* [JavaScript Events -](https://www.w3schools.com/js/js_events.asp) [w3schools.com](http://w3schools.com)
    
* [Introduction to events - Learn web development | MDN (](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Building_blocks/Events)[mozilla.org](http://mozilla.org)[)](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Building_blocks/Events)
