burgoyne burgoyne - 1 year ago 64
HTML Question

Can't remove a list item?

I am trying to remove a list item.

I add an item in like so:

var text = $('#item').val();
$('<li />',{html: text}).appendTo('ul.justList')

then remove it like so:

$("#justList li:last-child").remove();

Why does the last list item not remove? Any suggestions? Thanks so much!

Answer Source

Based on your add statement I would guess that you need a remove statement like:

    $("ul.justList li:last-child").remove();

If your add statement is working then this should be accessing the same ul

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