Reload / replace image jquery as a list item in <ul>
Hi all, I am adding images inside as a list item in an html unordered list and using jquery to dynamically insert an item into an unordered list using below code
for(var i=1; i<=5; i++){
$('ul').append('<li class="stage1">'+ stage1img[i]+'</li>')
}
Pictureths will be loaded when the page loads, now when I click the button I want to move all the images .ie the whole list element (li) with other elements as shown below I tried
for(var j=6; j<=10;j++){
$('li.stage1').replaceWith('<li>'+ stage1img[j]+ '</li>');
}
+3
4 answers
Javascript, ol, ol, ol. ol - :
<script type="text/javascript"><!--
$(document).ready(function() {
// when the tag with id="btn" is clicked
$('#btn').click(function() {
// removes all LI with class="cls" in OL
$('ol li.cls').remove();
});
});
--></script>
and then add new elements as you did before.
+1