Pittfall Pittfall - 1 year ago 62
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?

Answer Source

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/

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download