How to store in browser Local Storage elements created by jQuery?

前端 未结 2 1651
我寻月下人不归
我寻月下人不归 2021-01-26 12:35

I\'m using jQuery to add/remove input fields.

2条回答
  •  情歌与酒
    2021-01-26 13:12

    Try storing the element as a string. Here is a site that gives a nice implementation getting the outerHTML of an element. http://www.yelotofu.com/2008/08/jquery-outerhtml/

    jQuery.fn.outerHTML = function(s) {
       return (s) ? this.before(s).remove()
         : jQuery("<p>").append(this.eq(0).clone()).html();
    }
    

    Store that string and then reinsert the element using the appropriate jQuery method.

提交回复
热议问题