Replacing list of li in a div with another list of li in the same div
How do I replace a list of li in a div with another list of li in the same div? I tried this:
$("#divList").empty();
$('#divList').append('<li>' + textValue + '</li>');
I 开发者_如何学JAVAwant to clear out all data that was originally in the div and replace data using the same div at the same margin-left and margin-top as first list of li.
In my code, the div is emptied, but the li is not appended.
Grab the new lists html and then replace it : http://jsfiddle.net/bikerabhinav/V6g8d/
//Assuming the new li items fall under ul#list-new
var list_new = $('#list_new').html();
//Now replace the old one
$('#list-old').empty().append(list_new);
$('#divList').html('').append('<li>'+textValue+'</li>');
Guestimate. Also, you do realise that this will just append 1 li
, right?
精彩评论