This is my code:
$("#showing").append("<ul id='vrijemeObjava'");
for(i=0;i<App.vrijemeObjavljivanja.length;i++) {
$("#showing").append("<li><strong>" + App.vrijemeObjavljivanja[i] + "</strong></li>");
}
$("#showing").append("</ul>");
This is made inside a FB.api call. The "App.vrijemeObjavljivanja is an array of dates which I want to put in an ul. The array is put in <li></li>
but not in <ul>
.
The end result looks like this.
<ul id='vrijemeObjava'></ul>
<li>...</li>
<li>...</li>
<li>...</li>
Can someone please tell me why are the list items coming after the </ul>
.
When you append, you append entire elements (both the opening and closing tags). Try this instead:
$ul = $("<ul id='vrijemeObjava'></ul>");
for(i=0;i<App.vrijemeObjavljivanja.length;i++) {
$ul.append("<li><strong>" + App.vrijemeObjavljivanja[i] + "</strong></li>");
}
$("#showing").append($ul);