Hosting Solutions
mobile_logo Table of Contents
seal_frontseal_back

click

The 'click' event fires when the target element is clicked. It fires after the mousedown and mouseup events. If you were listening for those events also, they would both fire before the click event.

Quick Syntaxelement.addEventListener("click", clickHandler);
<script> function addEvents(){ var btn1 = document.getElementById('btn1'); var btn2 = document.getElementById('btn2'); btn1.url = "https://www.adamkhoury.com"; btn2.url = "https://www.webintersect.com"; btn1.addEventListener("click", btnClick); btn2.addEventListener("click", btnClick); } function btnClick(event){ window.location = event.target.url; } window.addEventListener("load", addEvents); </script> <button id="btn1">adam khoury</button> <button id="btn2">web intersect</button>

See Event Handling for more related information.

JavaScript

Events

clickdblclick