[英]JavaScript: How to save html text in HTML5 localStorage
我需要保存我附加的html()文本,每次單擊按鈕時,它應該存儲在HTML 5本地存儲中。
$('#add_new_criteria').on('click',function(){
$('#cyc_append').html(': Add new another criteria');
localStorage.setItem( ???? );
});
$('#add_new_criteria').on('click',function(){
$('#cyc_append').html(': Add new another criteria');
localStorage.setItem('textKey', $('#cyc_append').html());
});
第一個參數是您稍后將用於再次獲取數據的標識符。 第二個是要存儲的數據。
了解更多有關localStorage的信息
localStorage.setItem('key','value');
您可以在Chrome控制台->資源->本地存儲中檢查結果是否被保存。
請參閱以下鏈接https://developer.mozilla.org/en/docs/Web/API/Window/localStorage
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.