javascript - Parse, how to save Appended text -


let's have following code:

$('.button').click(function() {    $('body').append("<p>random text</p>"); }); 

where when .button clicked, text appended body.

how go saving text , having appear when user visits page. wise store in variable , send data browser under post or class?

hope isn't confusing, thanks!

this isn't ideal without creating server side or clientside db quick fix. if user switches browsers or clears cache storage gone.

http://jsfiddle.net/4gseg96g/1/

$(document).ready(function() {     // read localstorage.     function getstorage() {         var obj = localstorage.getitem('objname');         if(!obj) {             obj = '';         }         return obj;     }    // append localstorage obj, if any.    $('body').append(getstorage());       $('.button').click(function() {          console.log('click');        var str = "<p>random text</p>";        $('body').append(str);        var d = getstorage();        d += str;        console.log(d);        localstorage.setitem('objname', d);    });  }); 

Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -