I'm appending HTML code into a div, it's an unordered list. So first I do:
$('.placeholder').append('<ul>');
This works as expected. Then I do a loop for the list items:
$.each(headings, function(index, heading){
$('.placeholder').append('<li>' + heading + '</li>');
})
Then append the closing ul tag
$('.placeholder').append('</ul>');
The problem is the code comes out like so:
<ul></ul>
<li></li>
<li></li>
<li></li>
Why is it appending the closing ul tag at the beginning of the each loop when the code is written so it appends it afterwards?
$('.placeholder ul').append('<li>' + heading + '</li>');and ditch$('.placeholder').append('</ul>');