现象:电脑端单击一次,手机端单击两次响应
原因:电脑端oclick事件 手机端用touchstart事件,两种触发方式不一样
解决办法:添加oclick和touchstart事件,并使用 e.preventDefault()阻止其他点击;
$(document).ready(function() {
$('a').on('click', function(e) {
var id = $(this).attr("id");
e.preventDefault();
if(id=="photos")
window.open(id);
else
loadPage(id);
});
$('a').on('touchstart', function(e) {
var id = $(this).attr("id");
e.preventDefault();
if(id=="photos")
window.open(id);
else
loadPage(id);
});
});