In jQuery I want to remove all HTML inside of a div

前端 未结 6 976
梦谈多话
梦谈多话 2020-12-02 09:30

I have a div and I want to remove all the HTML inside of that div.

How can I do this?

6条回答
  •  感情败类
    2020-12-02 10:16

    suppose you have a html like this

    Hello
    Goodbye

    if you want all html under "first" div to remove permanently. just use this

    $('.first').empty();
    

    result will be like this

    for temporary(if you want to add them again) we can try detach() like

    $('.first').detach();
    

提交回复
热议问题