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