Delay a link click

后端 未结 8 2300
醉梦人生
醉梦人生 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:21

    Check this fiddle: http://jsfiddle.net/C87wM/1/

    Modify your toggle like this:

    $("a.question[href]").click(function(){
        var self = $(this);
        self.toggleClass("active").next().slideToggle(2000, function() {
            window.location.href = self.attr('href'); // go to href after the slide animation completes
        });
        return false; // And also make sure you return false from your click handler.
    });
    

提交回复
热议问题