Reputation: 341
I am trying to retrieve a saved url from a jquery cookie its saving in the cookie but its not retrieving the cookie url
$(document).ready(function() { $("#BGSelector a").click(function() {
var imgLink = $("img", this).attr("src");
$.cookie("html_img", "" + imgLink + "", { expires: 7 });
var imgCookieLink = $.cookie("html_img");
$("html").css("background", "url('" + imgCookieLink + "')"); }); });
thanks to xandy for the jquery script
Upvotes: 0
Views: 1019
Reputation: 341
this is funny all i did was call the cookie again
<script type="text/javascript">
$(document).ready(function() {
var imgCookieLink = $.cookie("html_img");
$("html").css("background", "url('" + imgCookieLink + "')");
});
</script>
Upvotes: 0
Reputation: 2908
<script src="js/jquery.js" type="text/javascript"></script>
<script src="js/jquery.cookie.js" type="text/javascript"></script>
<script type="text/javascript" >
$(document).ready(function() {
$("#BGSelector a").click(function() {
var imgLink = $("img", this).attr("src");
$.cookie("html_img", "" + imgLink + "", { expires: 7 });
var imgCookieLink = $.cookie("html_img");
$("html").css("background", "url('" + imgCookieLink + "')");
});
});
</script>
<div id="BGSelector" >
<a href="javascript:;"><img src="images.jpeg" /></a>
</div>
This is working in my browser.once check your code.
Upvotes: 2