http://codepen.io/schikara/pen/bpRMMq?editors=1010
$('#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').html(div); //apendd the div
$('#localStorageTest')[0].reset(); //clear the form
localStorage.clear();
});
答案 0 :(得分:0)
更改
$('.gettingValues').html(div);
要
$('.gettingValues').append(div);
html方法设置元素的内部HTML,覆盖可能已存在的任何html。追加只会添加新的div而不会覆盖以前的div。