移动开发中防止链接被多次点击

$("a").click(function(e) {
    e.preventDefault();//取消事件的默认动作。

    if (!$(this).data('isClicked')) {
        var link = $(this);

        // Your code on successful click

        // Set the isClicked value and set a timer to reset in 3s
        link.data('isClicked', true);
        setTimeout(function() {
        link.removeData('isClicked')
        }, 3000);
    } else {
        // do nothing or alert Anything you want to say 'Bad user!' haha
    }
});

猜你喜欢

转载自guangqiang.iteye.com/blog/1704544
今日推荐