$('.new_customer').click(function () {
var table = $("table");
var number = table.find('tr').length;
table.append('<tr id="' + number + '"><td><input type="button" class="btn btn-success btn-xs" value="Save" id="save' + number + '"></td></td>' +
'<td><input type="text"/></td>' +
'<td><input type="text"/></td>' +
'<td><input type="text"/></td><td><input type="text"/></td>' +
'<td><input type="text"/></td><td><input type="text"/></td><td><input type="text"/></td>' +
'<td><input type="text"/></td></tr>');
$(document).on('click', 'input[id^="save"]', function () {
$(this).parents('tr').children('td').each(function () {
if ($(this).children("input[type=button]").length==0) {
$(this).html($(this).children('input').val());
}
else{
$("input[type=button]").removeClass("btn-success").addClass("btn-warning").val("review");
}
});
});
});
Good Day! I am creating table with some information, which I want to save in localStorage. I am just a beginner and I have never done this thing before, could you help me? I tried to use something like that, but this code is invalid. I will be glad of any help. thank you.
var inputs= $("tr").children('input').val();
localStorage.setItem("customer", JSON.stringify(inputs));
Aucun commentaire:
Enregistrer un commentaire