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).
精彩评论