Adding a new listem to a list, and want to append to the end even if empty
Currently my DOM looks like:
<ol id="abc">
</ol>
Using ajax, I am appending to the last item in the list.
开发者_Python百科$("#abc li:last").after(newHtml)
This works if there is a li in the ol.
How can I get this same behaviour when the ol is empty initially.
$("#abc").append(newHtml)
.append
Simple stuff. Appends always appends it as the last child of an element.
Live Example
simple append does it, if I understand correctly
$("#abc").append(newLIHtml);
精彩评论