How to clear all
s’ contents inside a parent
?

前端 未结 14 1905
面向向阳花
面向向阳花 2020-12-07 10:10

I have a div

which has several child
s.

Example:

<
14条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-07 10:47

    jQuery's empty() function does just that:

    $('#masterdiv').empty();
    

    clears the master div.

    $('#masterdiv div').empty();
    

    clears all the child divs, but leaves the master intact.

提交回复
热议问题