开发者

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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜