循环后如何删除/隐藏图像

How do I remove/hide the image after the loop?

本文关键字:隐藏 图像 删除 何删除 循环      更新时间:2023-11-27

我是javascript的新手,我正在创建一个chrome打包的应用程序,我想做的是在循环后隐藏加载图像。这只是我代码的一部分,因为我只是指出如何在循环后隐藏图像。

 function AppMain()
    {
        jQuery("#loginID").hide();
        if(userLog == false)
        {
            jQuery.ajax({
                            type: 'POST',
                            url: 'something.aspx',
                            data: {action: 'someSearch', word: 'Wednesday', count: '4', page: '1'},
                            success: function(data){
                                    var json = jQuery.parseJSON(data);
                                    var htmlInfo='';
                                    for(i=0; i<json.length; i++)
                                    {
                                        var htmlCode = '<img class="full-image" src="/img/loading.png">' //this is the loading image
                                        htmlInfo = htmlInfo + htmlCode;
                                    }
//what do i need to add here so that the img will hide after the loop? 
                            }
            });
        }
    }

添加$('.full-image').remove();$('.full-image').hide();

向图像添加一个id,如:

var htmlCode = '<img class="full-image" id="loadingImg" src="/img/loading.png">' //this is the loading image

然后使用jquery,您可以以一种清晰的方式删除它:

$("#loadingImg").remove()