I'm looking if it is possible, without canvas, to listen to mouse x location constantly until they leave the page. In relation to this I want to create a neat parallax design.
I'm having trouble though getting the listener to work. I am very new to javascript so I'm doing as much googling as I can to figure it out. I found this piece of code off of stackoverflow for mouse listening. I got it to work but it to detect mouse movement only once on page. I'm going to safley assume I need to remove document.removeEventListener('mousemove', myListener, false);
var myListener = function () {
document.removeEventListener('mousemove', myListener, false);
};
document.addEventListener('mousemove', myListener, false);
I also read the documentations on clientX via MouseEvent.ClientX but I'm having trouble combine both into real time. Everything I attempt I have no results.
Example for onclick, where I want on mousemove
<!DOCTYPE html>
<html>
<head>
<title>clientX\clientY example</title>
<script>
function showCoords(evt){
alert(
"clientX value: " + evt.clientX + "\n" +
"clientY value: " + evt.clientY + "\n"
);
}
</script>
</head>
<body onmousedown="showCoords(event)">
<p>To display the mouse coordinates click anywhere on the page.</p>
</body>
</html>
Any resource or direction to lead me?