将保存的会话存储值插入HTML

时间:2015-11-10 14:54:06

标签: javascript session-storage

我如何重写这个以便我可以使用容器div中的存储值?

fiddle

<input id="email" type="text">
<div id="storage"></div>

<div class="container">This is some text. I want the value to show up in between the p tags here:<p></p>!</div>

JS:

(function () {
    var text = document.getElementById('email');
    text.addEventListener('keyup', function () {
        sessionStorage.text = text.value;
        document.getElementById('storage').innerHTML = 'Your stored value is ' + sessionStorage.text;
    }, false);
}());

0 个答案:

没有答案