Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 238
  • Last Modified:

how to get to the previous list of li element after removing them?

how to get to the previous list of li element after removing them?

For example, lets say I have the following

$("#list_A").html('');

This display in div ---------------> aaaaa bbbb ccccc
Now I clear out the div with --> $("#list A").html('');
And reload it with -------------->  ddddd eeeee ffffffff gggg
How do I return to the previous --> aaaaa bbbb ccccc
<div>
           <ul id="list_A">
                     <li>aaa</li>
                     <li>bbb</li>
                     <li>cccc</li>
                     <li>ddd</li>
                     <li>eee</li>
                     <li>ffffff</li>
                     <li>gggg</li>
           </ul>
</div>
0
areyouready344
Asked:
areyouready344
  • 2
1 Solution
 
leakim971PluritechnicianCommented:
For example : http://jsfiddle.net/zTygD/

var previous_list = $("li", "#list_A").detach();
$("#list_A").html("<li>ddddd</li><li>eeeee</li><li>ffffffff</li><li>gggg</li>");
alert("we put them back now");
$("#list_A").html(previous_list);

Open in new window

0
 
leakim971PluritechnicianCommented:
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now