How to clear all
s’ contents inside a parent
?

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

I have a div

which has several child
s.

Example:

<
14条回答
  •  醉梦人生
    2020-12-07 10:46

    jQuery recommend you use ".empty()",".remove()",".detach()"

    if you needed delete all element in element, use this code :

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

    if you needed delete all element, Use this code:

    $('#target_id').remove();
    

    i and jQuery group not recommend for use SET FUNCTION like .html() .attr() .text() , what is that? it's IF YOU WANT TO SET ANYTHING YOU NEED

    ref :https://learn.jquery.com/using-jquery-core/manipulating-elements/

提交回复
热议问题