jQuery如何将图像源存储到临时内存中并在以后检索它

Pra*_*pta -2 javascript jquery local-storage

请查看下图.

在此输入图像描述

当我点击隐藏图像时,所有图像都显示为替换为静态图像,稍后当我取消选中它时,它必须立即显示原始图像.

<div id="log_contents">    
    <span style="color:blue;"><b>Public chat</b> with <b>dragos123</b></span> <br><br>    
    <div class="chat-line"> 
        <span class="dialogue_time">  11:00:39 AM &nbsp;</span>
        <span style="background-color:FFF;">debasish:</span>
        <span style="background-color:FFF;"><img  style="cursor:pointer; max-height:80px;" src="http://localhost/myshowcam/files/stickers/msc-1427684408.gif" title=":party1"></span>
    </div>

    <div class="chat-line"> 
        <span class="dialogue_time">  11:01:43 AM &nbsp;</span>
        <span style="background-color:ffff88;">pkk:</span>
        <span style="background-color:ffff88;">hiiiiiiiiiiiiii</span>
    </div>

    <div class="chat-line"> 
        <span class="dialogue_time">  11:02:03 AM &nbsp;</span>
        <span style="background-color:ffff88;">pkk:</span>
        <span style="background-color:ffff88;"><img  style="cursor:pointer; max-height:80px;" src="http://localhost/myshowcam/files/stickers/msc-1427684892.gif" title=":1min"></span>
    </div><div class="pagination" style=""></div>

</div>
Run Code Online (Sandbox Code Playgroud)

请提供宝贵的反馈意见.

谢谢.

Kam*_*ami 6

您需要在某处保存有关原始版权的信息,否则将无法恢复此更改.

我会将初始代码更改为类似的内容

$("#log_contents").find('img').each(function() {
    $(this).data('img-org', $(this).attr('src'));
    $(this).attr('src', 'img/hide-image.gif');
});
Run Code Online (Sandbox Code Playgroud)

要扭转它,你只需要做相反的事情

$("#log_contents").find('img').each(function() {
    $(this).attr('src', $(this).data('img-org'));
});
Run Code Online (Sandbox Code Playgroud)