javascript - remove an .append() to return an element to it's original state -


i'm loading ul image slider need remove images (ul) , revert original state (before javascript manipulations) when slider closed because later need reload ul set of different images.

here how i'm loading slider.

 var get_images = [ "show_1.jpg", "show_2.jpg", "show_3.jpg", "show_4.jpg"];   $.each(get_images, function(i,img){  $('#container ul').append('<li><a href="#" class="thumbnail"><img src="'+img+'"/></a></li>');  }); 

i think might looking for:

var get_images = ["show_1.jpg", "show_2.jpg", "show_3.jpg", "show_4.jpg"]; var original = $('#container ul').html(); $.each(get_images, function (i, img) {     $('#container ul').append('<li><a href="#" class="thumbnail"><img src="' + img + '"/></a></li>'); }); $("#revert").click( function() {     $('#container ul').html(original); }); 

the revert button demonstration purposes. idea save original content can revert later if needed.

fiddle


Comments

Popular posts from this blog

java - How to Configure JAXRS and Spring With Annotations -

visual studio - TFS will not accept changes I've made to a Java project -

php - Create image in codeigniter on the fly -