Differences between detach(), hide() and remove() - jQuery

后端 未结 5 2054
忘了有多久
忘了有多久 2020-11-28 02:52

What is the functional difference between these three jQuery methods:

  • detach()
  • hide()
  • remove()
5条回答
  •  眼角桃花
    2020-11-28 03:15

    hide() sets the matched element's display to none.

    detach() removes the matched elements, including all text and child nodes.

    This method stores all the data associated with the element and so can be used to restore the element's data as well as event handlers.

    remove() also removes the matched elements, including all text and child nodes.

    However, in this case only the element's data can be restored, not its event handlers can't.

提交回复
热议问题