Reputation: 639
I have dynamically added multiple elements using jquery. Now i want to save that page, so that if i reload that page everything should be there. How should i do that?
HTML code
<body>
<button id="add_div" >Add Div</button>
<button id="add_button">Add Button</button>
</body>
Jquery code
$(document).ready(function(){
// Add div function
$("#add_div").click(function () {
var p= $("body").append(
'<div class="module_holder">Hello there</div>');
$(".module_holder").draggable().resizable().css( "background-color","red");
});
// Add Button function
$('#add_button').on('click',function(){
var r= $('<input type="button" value="new button"/>');
$("body").append(r);
});
});
Upvotes: 2
Views: 294
Reputation: 1426
you have to use localstorage, if your website can be accessed from number of browsers than you can use common jaydata library to work with local storage
You have to save your data on any server using server side technology like ASP.NET or PHP or JSP and you can retrieve your information on page load using AJAX. If there is any content stored on server side than you have to load with page, if there is nothing it means that you have to just load only two buttons.
Upvotes: 2