在Cookie中保存更多ID

时间:2017-06-23 09:12:50

标签: javascript cookies

也许有人有想法?我想把它放在带有保存按钮的Cookie中是可能的吗?

    <td id="dropzoneorg">File from Server</td>
    <td id="dropzoneteil">File from Server</td>
    <td id="dropzoneref">File from Server</td>

https://jsfiddle.net/michiffm/tvd4bs6v/4/

这很好用(我复制此代码)

如何保存更多ID? dropzoneorg,dropzoneteil,dropzoneref ....

他现在只保存了一个dropzoneorg

1 个答案:

答案 0 :(得分:0)

只是一个基本/愚蠢的例子......这是如此基本,我认为你必须掌握并理解基础知识。

//This part fetches the data from the inputs.
var dropzoneorg = $('#dropzoneorg').html();
var dropzoneteil = $('#dropzoneteil').html();
var dropzoneref = $('#dropzoneref').html();

//This part saves the data fetched to the localstorage, so that you can restore it later.
localStorage.setItem('dropzoneorg', dropzoneorg);
localStorage.setItem('dropzoneteil', dropzoneteil);
localStorage.setItem('dropzoneref', dropzoneref);

//If you want to restore the data from the localStorage to your application
dropzoneref = localStorage.getItem('dropzoneref');

//If you want to put that data back in your form: 
$('#dropzoneref').html(dropzoneref);