burgoyne burgoyne - 3 months ago 17
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!


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