I need the equivalent plain vanilla JavaScript code for the following jQuery.
$(document).on("mousemove touchmove", function(e) {
console.log(e.touches[0].pageX);
//code
});
My problem is that I have an idea how this can be implemented by using jQuery, but having problems with turning it into pure javascript. I'm trying this, but it doesn't work.
['mousedown','touchstart'].forEach(function(evt){
document.addEventListener(evt,function(e){
console.log(e.touches[0].pageX);
//code
});
});
i need plain vanilla javascript to perform certain task. please help