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

sql - Postgresql error: "failed to find conversion function from unknown to text" -

javascript - Why in IE loading image not show at center bottom of page? -

javascript - Play sound in jquery mobile on different pages -