Delay a link click

后端 未结 8 2317
醉梦人生
醉梦人生 2020-12-18 12:57

Here\'s the fiddle I\'m working with: http://jsfiddle.net/Scd9b/

How can I delay the href function after the click?

For example a user clicks on the link, th

8条回答
  •  无人及你
    2020-12-18 13:27

    How about e.preventDefault in your click handler. Then do a setTimeout that takes you to your destination?

    $("a.question").click(function(e){
        e.preventDefault();
        $(this).toggleClass("active").next().slideToggle("slow");
        setTimeout('window.location.href=' + $(this).attr(href), 2000);
    });
    

提交回复
热议问题