Set cookies to text value using jQuery -


i add cookies function. in example, want browser remember value of p, "number one" after input button #sting clicked. when page refreshed empty p tag have text "number one."

the html

<p id="place"></p> <input id="sting" type="submit" value="run"/> 

the js

$(document).on('click', '#sting', function(){ $('#place').text("number one"); }); 

jsfiddle: https://jsfiddle.net/xwgj4w67/

i have looked jquery cookie plugin(https://github.com/js-cookie/js-cookie/tree/v1.5.1), unsure of how use it. happy examples either or without plugin. thanks.

you can use local storage store values browser:

to set value in local storage:

localstorage.setitem('place', "number one"); 

to value local storage:

localstorage.getitem('place'); 

Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -