Raffy T Lawrence Raffy T Lawrence - 1 year ago 52
HTML Question

JavaScript: How to save html text in HTML5 localStorage

I need to save my appended html() text, every time i click the button it should be store in HTML 5 local storage.

$('#add_new_criteria').on('click',function(){
$('#cyc_append').html(': Add new another criteria');
localStorage.setItem( ???? );

});

Answer Source
$('#add_new_criteria').on('click',function(){
     $('#cyc_append').html(': Add new another criteria');
     localStorage.setItem('textKey', $('#cyc_append').html());

});

The first argument is the identifier you’ll later use to get the data out again. The second is the data you want to store.

Read more on localStorage

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download