Alex Rivera | Logout

jQuery remove all list items from an unordered list

Asked 2011-08-09T23:01:16.163
142

I forgot the jQuery command that will clear all list elements from a list. I did a bit of searching, done it a bunch of times before, but just simply forgot the command.

$("ul").clear()
$("ul").empty()

both didn't seem to accomplish this.. which command is it again?

UPDATE:
Thanks guys, I must have some syntax error on my selector.

Edit
Report

1 Answer

19

As noted by others, $('ul').empty() works fine, as does:

$('ul li').remove();

JS Fiddle demo.

answered 2011-08-09T23:05:52.757

Your Answer