手机端触摸位置获取

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;
    }
}

 

posted @ 2016-11-10 11:49  狄枫  阅读(315)  评论(0编辑  收藏  举报