📅  最后修改于: 2020-11-26 01:08:23             🧑  作者: Mango
jQuery empty()方法用于从所选元素中删除所有子节点和内容。此方法不会删除元素本身。
如果要删除元素而不删除数据和事件,则应使用detach()方法。
如果要删除元素及其数据和事件,则应使用remove()方法。
句法:
$(selector).empty()
让我们以一个示例来演示jQuery empty()方法。
Twinkle, twinkle, little star,
How I wonder what you are!
Up above the world so high,
Like a diamond in the sky.
Twinkle, twinkle, little star,
How I wonder what you are!
This poem is written inside the div.
This paragraph is written outside the div.
The jQuery Example
Click any of the box given below to see the result:
Click me!
Click me!
Click me!