jQuery: Remove All List Elements but First One

by trippinbilly25

Here is a quick jQuery snippet to remove all DOM elements from a list except for the first one:

$("li:not(:first)").remove();

Where would this be useful? Say you are adding user choices to a list for a query and you have a remove event attached to each item. But you want the user to be able to remove all of their choices and start a new list of choices?

Enjoy!