$('ul li:not(:first):not(:last)').remove();
或使用特定的ID:
$('#yourul li:not(:first):not(:last)').remove();
如果你有一个jQuery对象与你的ul:
$(yourul).find('li:not(:first):not(:last)').remove();