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.
Comments
Post a Comment