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
Post a Comment