Home > front end > The user to enter text input on the page, it is necessary to save to another page, and open there ne
The user to enter text input on the page, it is necessary to save to another page, and open there ne
Time:11-02
Every time I use the local store, but can only save one, because the user to enter a page, there is only one and I want to save to another page, with setitem and the getitem method are the same every time, I want to realize user input accumulation preservation, somewhat akin to save the text document, I now would be a main innerHTML dynamic insertion method, but can't forever and accumulative preservation, experience how to solve the bosses to help overcome? Thank you!!!
CodePudding user response:
enter
& lt; Input the id="t1" & gt; & lt; Button onclick="save ()" & gt; Save & lt;/button> & lt; Script> The function the save () { Var t1=document. GetElementById (" t1 ") Var mySave=localStorage [] "mySave"? JSON. Parse (localStorage [" mySave "]) : [] MySave. Push (t1) value) LocalStorage [" mySave "]=JSON. Stringify (mySave) t1.valuehttps://bbs.csdn.net/topics/="" } & lt;/script>