JQuery: how to remove list items from lists?

Is there any way with jQuery to remove all LI inside UL with id 'myList'?

+3
source share
2 answers

The following will do the trick:

$('#myList li').remove();

But you should familiarize yourself with jQuery supported selectors and manipulation

+9
source

A slightly simpler approach:

$("#myList").empty();

See empty(). Another answer works fine for this, but it becomes more inconvenient for other elements that may have different child elements (e.g. tables).

+6
source

Source: https://habr.com/ru/post/1724840/


All Articles