Answers for "clientX and clientY in html"

8

Javascript track mouse pointer

var pointerX = -1;
var pointerY = -1;
document.onmousemove = function(event) {
	pointerX = event.pageX;
	pointerY = event.pageY;
}
setInterval(pointerCheck, 1000);
function pointerCheck() {
	console.log('Cursor at: '+pointerX+', '+pointerY);
}
Posted by: Guest on November-03-2020
0

svg clientx

function clicked(evt){
    var e = evt.target;
    var dim = e.getBoundingClientRect();
    var x = evt.clientX - dim.left;
    var y = evt.clientY - dim.top;
    alert("x: "+x+" y:"+y);
}
Posted by: Guest on August-14-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language