Pittfall Pittfall - 5 months ago 23
jQuery Question

How do you remove and <li> from a <ul> by Id?

I have:

<ul id="ulId">
<li id="firstli">
<li id="secondli">

and I am trying to remove

This is what I have tried based on some reading.

$('#ulId secondli').remove();


$('#ulId > secondli').remove();

but these 2 methods did not work. Any suggestions?


Try this:


In jQuery, you refer to the ID of an element with a # in front of it. See http://api.jquery.com/id-selector/