首页 > 代码库 > 手机端触摸位置获取

手机端触摸位置获取

function touch(event) {
    var event = event || window.event;
    switch (event.type) {
    case "touchstart":
        console.log(event.touches[0].clientX + "," + event.touches[0].clientY);
        break;
    case "touchend":
        console.log(event.changedTouches[0].clientX + "," + event.changedTouches[0].clientY);
        break;
    case "touchmove":
        event.preventDefault();
        console.log(event.touches[0].clientX + "," + event.touches[0].clientY);
        break;
    }
}

 

手机端触摸位置获取