How to remove an element's content with JQuery?

前端 未结 4 998
借酒劲吻你
借酒劲吻你 2021-02-18 14:54

Say I have a div and some content inside it.

Content

With JQuery, how do I empty the div without removing the di

4条回答
  •  梦谈多话
    2021-02-18 15:30

    You can use the empty function to remove all the child nodes (all its content) of an element:

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

    The empty function will also remove all the event handlers and the jQuery internally cached data.

提交回复
热议问题