我想用js(jquery)实现一个点击效果,可是touchstart之后touchend事件不触发,执行preventDefault确认可以执行touchend,可是页面就不能正常滚动了.求解题的正确方法
贴上我的代码:
$(document).delegate('.openurl', 'touchstart', function(e) {
//生成遮罩
var touchEffectModal = '<div class="touch-effect"></div>';
$(this).append(touchEffectModal);
e.preventDefault();
}).delegate('.openurl', 'touchend', function(e) {
//移除遮罩
$(this).find('.touch-effect').remove();
});
event.preventDefault
和页面滚动是鱼和熊掌,二者不可得兼。
题主除了添加绑定 touchend
事件外,再同样添加个 touchcancel
事件试试。