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

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -