/*图片复选功能*/
$(".TabListItem .ForFun").click(function(){
//如果已经被选中
if($(this).hasClass("AddImg")){
$(this).removeClass("AddImg");
}
//如果没被选中
else{
$(this).addClass("AddImg");
}
});
/*touch事件*/
$(".ForFun").on({
touchstart: function(e){
timeOutEvent = setTimeout("longPress()",500);
e.preventDefault();
return false;
},
touchmove: function(){
clearTimeout(timeOutEvent);
timeOutEvent = 0;
},
touchend: function(e){
clearTimeout(timeOutEvent);
timeOutEvent = ShortLeave();
e.preventDefault();
return false;
}
})
});
同一个div不能绑定多个事件么?为什么我的touch能用之后click不能用呢?
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
2条回答 默认 最新
俊刚、 2016-11-03 11:02关注可以绑定多个事件的。
例:<!DOCTYPE html> <html> <body> <div onmouseover="mOver(this)" onmouseout="mOut(this)" onclick="this.innerHTML='再见!'" style="background-color:green;width:120px;height:20px;padding:40px;color:#ffffff;">把鼠标移到上面</div> <script> function mOver(obj) { obj.innerHTML="谢谢" } function mOut(obj) { obj.innerHTML="把鼠标移到上面" } </script> </body> </html>解决 无用评论 打赏 举报