简体   繁体   English

Ajax调用完成后无法删除进度条

[英]Cannot remove the progress bar after the ajax call is completed

What am I doing wrong? 我究竟做错了什么?

progressbar : function() { 
    var $progress = $('<div>', {'class' : 'progress-bar', height : '2px'});
    var width = 0,
        load  = 0;
    $(document).on({ 
        ajaxSend : function(event, req, set) {
            $('body').append($progress);            
            load = setInterval(function(e) {
                if (width > 100) {
                    clearInterval(load);
                }
                width++;
                $('.progress-bar').width(width + '%');
            }, 10);
        },
        ajaxComplete : function(){
            width = 0;
            clearInterval(load);
            $('body').remove('.progress-bar');
            //$('.progress-bar').fadeOut();
        }
    });
}

The fadeOut function works but I cannot remove the .progress-bar from the DOM. fadeOut函数有效,但是我无法从DOM中删除.progress-bar。 I call the above function on window - load & click. 我在窗口上调用上述功能-加载并单击。

$('body').remove('.progress-bar'); 

替换为

$('.progress-bar').remove();

您必须使用$('.progress-bar').remove()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM