我想在我的jsp中動態生成以下種類的嵌套li對象。我應該如何做到這一點。我無法使用簡單的document.createElement(「LI」)來解決問題。和appendElement,因爲我也想將類添加到該元素。如何使用javascript/jquery動態生成這種嵌套的li對象?
<li class="level1">
<div class="thumb">
<a href="detail.html#"><img src="images/comments1.gif"
alt="" /></a>
</div>
<div class="desc">
<div class="commentlinks">
<a href="detail.html#" class="reply">Reply</a> <a
href="detail.html#" class="like">Like</a> <a
href="detail.html#" class="dislike">Dislike</a>
</div>
<h5>
<a href="detail.html#" class="colr">By MySebbb:</a>
</h5>
<p class="time">7 months ago</p>
<div class="clear"></div>
<p class="txt">Lorem ipsum dolor sit amet, consectetuer
adipiscing elit. Sed elit. Nulla sem risus, vestibulum in,
volutpat eget, dapibus ac, lectus. Curabitur dolor sapien.</p>
</div>
</li>
您是如何嘗試到目前爲止? –