http://codepen.io/anon/pen/mPBQxX
$('.stored').keyup(function() {
localStorage[$(this).attr('name')] = $(this).val();
});
答案 0 :(得分:0)
您在onSubmit回调结束时每次提交后清除LocalStorage。也许清除表单值而不是清除存储。
$('#localStorageTest').submit(function(e) {
e.preventDefault();
var email = $('#email').val();
var name = $('#name').val();
var message = $('#message').val();
var div = "<div><span>" + name + "</span><span >" + email + "</span><span>" + message + "</span><input type='button' value='Edit' name='editHistory'><input type='button' value='Delete' name='deleteHistory'></div>"; //add your data in span, p, input..
//alert(div);
$('.gettingValues').append(div); //apendd the div
$('#localStorageTest')[0].reset(); //clear the form
localStorage.clear(); >>>>>>>>>> RESETTING HERE >>>>>>>>>>>>>>>>>>>>>
});