I have a script from this demo: tutorialzine.com
As you can see the cookie is saved as plain text. However I need it to be saved as a link. So I tried:
// If the cookie has been set in a previous page load, show it in the div directly:
if(cookie) $('.jq-text').text(cookie).show();
$('.fields a').click(function(e){
var text = $('#inputBox').val();
// Setting a cookie with a seven day validity:
$.cookie('demoCookie',text,{expires: 7, path: '/', domain: 'domain.com'});
$('.jq-text').attr('href', text).html(text);
I don't know what exactly to change in order to 'attr' the 'var text' and save it as $cookie.
please take a look at the demo: JsFiddle
The problem seems to be because of the variable "cookie". Renaming it to "demoCookie" seems to fix the problem...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.