0

This is my jquery source

enter image description here

And this is my html source.

enter image description here

The add element in list works but remove doesn't work.

However, when I remove the parameter from .remove() it removes the element, but I will have more than one ul list in a page. I need to specify ul list

0

3 Answers 3

2

Your selector is incorrect. Use

 $('ul#family_list li:last').remove();

or

 $('ul#family_list').remove('li:last')

You should also read docs properly

Sign up to request clarification or add additional context in comments.

Comments

0

Your selector to remove is backwards. It should be

$('ul#family_list li:last').remove()

Also, in future, please post your code in code tags, rather than posting an image of it

2 Comments

Sorry, I am quite new to stackoverflow. How do you write codes ?
@mistysnake, Just leave 4 space at the begining of line then write your code. for inline code write between ``
0

try this: $('ul#family_list li:last').remove()

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.