How to move an element into another element?

前端 未结 15 2532
無奈伤痛
無奈伤痛 2020-11-22 03:35

I would like to move one DIV element inside another. For example, I want to move this (including all children):

...
15条回答
  •  無奈伤痛
    2020-11-22 04:28

    my solution:

    MOVE:

    jQuery("#NodesToMove").detach().appendTo('#DestinationContainerNode')
    

    COPY:

    jQuery("#NodesToMove").appendTo('#DestinationContainerNode')
    

    Note the usage of .detach(). When copying, be careful that you are not duplicating IDs.

提交回复
热议问题