How to add event listener in javascript
I`m trying to add onclick event in javascript
1 Answer
In Javascript, there are a lot of events such as :
- click
- dblclick
- mouseenter
- mouseleave
- mousemove
and there are three ways to assign events to HTML elements:
- Inline event handlers
- Event handler properties
- Event listeners
I will show you how to add onclick event in javascript using Inline event handlers
example
<button onclick="alert(Date())">What the time is?</button>
answer Link