Relative Content

Tag Archive for javascriptaddeventlistener

How to output variable values from addeventlistener

let xc = null; let yc = null; var el = document.getElementById(“canvas”); el.addEventListener(‘mousemove’, function(f) { console.log(‘Coordinates: x=’ + f.clientX + ‘ y=’ + f.clientY); xc = f.clientX; yc = f.clientY; return xc; return yc; }) console.log(xc, yc); As a result, when you touch the screen, the coordinates are shown, but are not updated separately via […]

Trying to set a form’s file input.value = null inside addEventListener

I’m trying to get rid of some errors in the web console of my internal site. This JS is not meant to serve as proper form validation or be security minded, it’s only done to apply a quick fix on the frontend of a completely internal site to limit the upload size and clear the form’s file input if the size exceeds 29M. I’m just curious of how to clear the input without having these errors.