“加载gif”背景图片(IE / Edge)存在问题

时间:2018-08-29 15:14:52

标签: javascript jquery html css

我正在尝试向按钮添加加载gif,但是在Edge和IE中遇到问题。它有时只显示在几个按钮上。

基本上,我正在做的是将按钮变暗,然后使用具有背景gif加载图标的jquery动态地将按钮包装成一个范围。不幸的是,它不能在IE或Edge中工作(可以在几个按钮上使用,但不是大多数)。

添加加载按钮的Javascript:

$("body").on("click", ".loading-button", function() {
    $(this).wrap("<span class='disabled-loading-icon'></span>");
    $(this).addClass("disabled-loading");
});

用于加载gif的CSS:

.disabled-loading {
    opacity: 0.2;
}

.disabled-loading-icon {
    opacity: 1;
    background-image: url("/Images/loader.gif") !important;
    background-color: transparent !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
    background-size: contain !important;
}

路由很好,并且可以在Chrome和Firefox中正常工作。

该html被添加到IE / Edge中,但实际上并不是一直都在做gif动画,通常只是变暗并加载页面。

HTML:

<span class="disabled-loading-icon"><a class="button secondary wide center loading-button disabled-loading" href="https://localhost:44327/Login/Login">Continue</a></span>

任何可能的解决方法或解决方案?我认为,如果我手动添加包裹的“ span”,它将起作用,但我不希望这样做。

2 个答案:

答案 0 :(得分:0)

几个小时后,我知道了。对于IE / Edge,您需要将js包装为超时

    $("body").on("click", ".loading-button", function(e) {
    var $this = $(this);
    setTimeout(function() {
        $this.wrap("<span class='disabled-loading-icon'></span>");
        $this.addClass("disabled-loading");
    }, 1);
});

答案 1 :(得分:0)

尝试这个。它将有所帮助

delete from documents
  where docu_id = "Y" 
    and
    where attachments @> '[{"attach_id": "X"}]'