开发者

jQuery: how to delete list items from lists?

Is 开发者_如何学Cthere a way with jQuery to remove all the LIs inside a UL with an id of 'myList'?


The following will do the trick:

$('#myList li').remove();

But you should familiarize yourself with jQuery's supported selectors and manipulation


Slightly simpler approach:

$("#myList").empty();

See empty(). The other answer works fine for this but gets more awkward for other elements that can have different child elements (eg tables).

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜