这是我正在使用的 fiddle :http://jsfiddle.net/Scd9b/
如何在点击后延迟 href 函数?
例如,用户单击链接,消息向下滑动片刻...,2 秒后用户继续访问链接到的页面。
抱歉大家忘了说还有一些 anchor 是没有链接的。
最佳答案
您可以通过设置 window.location 来模拟导航到一个页面。因此,我们将使用 preventDefault
阻止链接的正常功能,然后在 setTimeout
中,我们将设置正确的 window.location:
https://codepen.io/anon/pen/PePLbv
$("a.question[href]").click(function(e){
e.preventDefault();
if (this.href) {
var target = this.href;
setTimeout(function(){
window.location = target;
}, 2000);
}
});
关于javascript - 延迟链接点击,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8775541/