• DS1 Records:

    How to remove HTML elements inside UL using jQuery?

    I have the following HTML code:

    <ul class="message" id="stats-results"> <li>DS1 Records: <span id="ds1Count"></span></li> <li>DEV Records: <span id="devCount"></span></li> </ul> 

    Is there an easy way to completely remove li elements from ul using jQuery?

    +4
    source share
    3 answers

    There is a method just for that, empty ()

     $('#stats-results').empty(); 

    Description: Remove all child nodes of the set of matched elements from the DOM.

    No need for "tricks."

    +5
    source
     $("#stats-results").html(""); 

    This will remove all li elements

    +1
    source

    Try $('ul.message li').remove();

    0
    source

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


    All Articles