所以我試圖做一個簡單的便箋thingy使用localstorage你可以鍵入並自動保存。在localstorage上保存換行
當我按下換行符時,出現問題。本地存儲不適用換行符。
HTML:
<div contenteditable="true" class="s_content">Type something, press linebreak and type something again. Then refresh</div>
JS:
$('div.s_content').text(localStorage.getItem ("foo"))
$("div.s_content").on("keyup paste", function() {
localStorage.setItem ("foo", $('div.s_content').text())
});
嘗試輸入一些東西,按回車鍵並輸入更多的東西。然後刷新頁面。
如何將<br>
/line-break
應用於本地存儲?
爲什麼我沒有想到這一點。謝謝 – jQuerybeast 2012-02-17 07:37:33