This is my jquery source
And this is my html source.
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
Your selector is incorrect. Use
$('ul#family_list li:last').remove();
or
$('ul#family_list').remove('li:last')
You should also read docs properly
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
试试这个: $('ul#family_list li:last').remove()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.