Reputation: 68740
Is there a way with jQuery to remove all the LIs inside a UL with an id of 'myList'?
Upvotes: 3
Views: 191
Reputation: 625007
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).
Upvotes: 6
Reputation: 5613
The following will do the trick:
$('#myList li').remove();
But you should familiarize yourself with jQuery's supported selectors and manipulation
Upvotes: 9