javascript - Js mouse click events -


is there event function activates if mouse clicked goes this:

var mouseclick = function(e) {   if(e.mouseclick==true){      alert("hi");    } } 

i'm trying make if click area of canvas.

you can listen 'click' event:

var el = document.getelementbyid('my-div'); el.addeventlistener('click', handleclick, true);  function handleclick() {   alert('hi'); } 

see working snippet below:

var el = document.getelementbyid('my-div');  el.addeventlistener('click', handleclick, true);    function handleclick() {    alert('hi');  }
#my-div {    background-color: red;    height: 30px;    width: 100px  }
<div id="my-div">    click me!  </div>

here mdn documentation eventtarget.addeventlistener


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -