jquery - Save path to the remote img with cookies? -
i'm using jquery (1.10.1) + backstretch , cookies plugin. idea set remote img
, save path img using cookies
.
first part wasn't hard:
$("#own").click(function(e) { e.preventdefault(); var own = $("input#img-link").val(); $(".backstretch img").attr("src", own); $.cookie("postcode", $("input[name=postcode]").val()); }); if ( typeof $.cookie("postcode") !== "undefined") { $("input[name=postcode]").val($.cookie("postcode")); }
now i'm litle bit confused of how can set cookies work it. i've found example example link:
$('#go').click(function(){ $.cookie('postcode', $('input[name=postcode]').val()); }); //retrieve cookie on load if it's not undefined if(typeof $.cookie('postcode') !== 'undefined'){ $('input[name=postcode]').val($.cookie('postcode')); }
cookies store data within browser how can push cookies, on every page refresh img loaded cookies?
instead of setting image's property, setting other elements properties
$("#own").click(function(e) { e.preventdefault(); var own = $("input#img-link").val(); $(".backstretch img").attr("src", own); $.cookie("backstretch-img", own); }); var own = $.cookie("backstretch-img"); if ( typeof own !== "undefined") { $(".backstretch img").attr("src", own); }
Comments
Post a Comment