How to clone (and restore) a DOM subtree

前端 未结 4 1999
别那么骄傲
别那么骄傲 2021-01-04 04:30

I would like to modify a DOM subtree and restore it after a while. How can I save a sub-tree copy aside (to play with the actual subtree)? How can I restore the saved copy a

4条回答
  •  [愿得一人]
    2021-01-04 05:03

    you can use $.data()... method

        $.data(document.body, "sortElement", "0"); //set value
        $.data(document.body, "sortElement");        //read value
    

    this was you can store all waht you want in a dictionary type - and then reuse it later.

    http://api.jquery.com/jQuery.data/

提交回复
热议问题