【问题标题】:how to use show() and hide() with delay()?如何将 show() 和 hide() 与 delay() 一起使用?
【发布时间】:2013-10-02 21:35:06
【问题描述】:

我想在单击按钮后显示一段时间的图像,并且在显示图像时,我想隐藏按钮。 这是我的代码

function showimage(button, image, imagesrc){
    $(button).click(function(){
        if ($('img#'+image).length === 0) {
            $('<img id=' + image + ' src=' + imagesrc + ' style={display: none;}>').insertBefore(button);
        }

        $(button).hide();

        $('img#'+image).slideDown(500).delay(2000).slideUp(500);

        $(button).show();
    });
};

但是show()hide() 不会跟随延迟,我该怎么办?

【问题讨论】:

标签: jquery


【解决方案1】:

你必须在演出前使用延迟。

    $(button).delay(500).show(0);

    $(button).delay(500).hide(0);

【讨论】:

    猜你喜欢
    • 2011-05-29
    • 2011-06-07
    • 2018-02-27
    • 2016-10-06
    • 1970-01-01
    • 1970-01-01
    • 2015-08-15
    • 2015-02-12
    • 2016-07-29
    相关资源
    最近更新 更多