Why this code is not working? Meaning nothing get displayed into the ul tag.
$("#server").each(function()
{
var textValue = $(this).text();
$('#list li').eq(counter).append('<li>' + textValue + '</li>'); // <-- not working
$('#list li').eq(counter).insertAfter('<li>' + textValue + '</li>'); // <-- or not working
$('#list')append('<li>' + textValue + '</li>'); // <-- or working
});
<div>
<ul id="list"></ul>
</div>
#servercan only match a single element.counteris undefined.#listdoes not contain any items, so#list liwill not match anything.append.