js绑定触摸事件
想在jsp页面中给button绑定touchstart和touchend事件,实现和onmouseup和onmousedown一样的效果,跪求大神赐教...
想在jsp页面中给button绑定touchstart和touchend事件,实现和onmouseup和onmousedown一样的效果,跪求大神赐教
展开
1个回答
展开全部
<script>
var touchStartEle;
window.onload=function(){
touchStartEle=document.getElementById("touchStart");
touchStartEle.addEventListener("touchstart",function(){
console.log("touchstart");
});
touchStartEle.addEventListener("touchend",function(){
console.log("touchend");
});
}
</script>
</head>
<body>
<div id="touchStart" style="width:200px;height:20px;background:red;"></div>
</body>
var touchStartEle;
window.onload=function(){
touchStartEle=document.getElementById("touchStart");
touchStartEle.addEventListener("touchstart",function(){
console.log("touchstart");
});
touchStartEle.addEventListener("touchend",function(){
console.log("touchend");
});
}
</script>
</head>
<body>
<div id="touchStart" style="width:200px;height:20px;background:red;"></div>
</body>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询