Categories
Java Script Tutorials

Registering JavaScript Events can be Tricky

When registering JavaScript Events we need to provide the handler. That handler is called when ever a specified event is clicked. function clickHandler() { alert(‘Window is clicked’) } window.addEventListener(‘click’, clickHandler()) The problem with above code is that, we will see the alert as soon as windows loads. The expected result is show alert whenever we […]