我想包括一个迷你菜单20px乘20px图像的潜在背景。 当用户点击其中一个人时,身体背景图像将会更改,并且选择将保存为用户选择的内容。jquery滑块来改变身体背景
我想过使用滑块,但我不知道如何能够在li
中获得图像,并且能够根据选择更改主体css。
任何想法?
快乐7月4日
编辑 我试图保存在cookie中的图像网址,它不工作寿,其节省的Cookie,但它不是检索cookie的内容
编辑 以下作品,!!!!!!!但背景颜色始终是白色的,即使我添加 一个$("html").css("background-color","red");
FIX,在URL的末尾添加颜色
$("html").css("background", "url('" + imgCookieLink + "') no-repeat fixed center top #343837");
$(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 type="text/javascript">
$(document).ready(function() {
$("#BGSelector a").click(function() {
var imgLink = $("img", this).attr("src");
$.cookie("html_img", "" + imgLink + "", { path: '/vitamovie', expires: 7 });
var imgCookieLink = $.cookie("html_img");
$("html").css("background", "url('" + imgCookieLink + "') no-repeat fixed center top");
});
});
</script>
<script type="text/javascript">
$(document).ready(function() {
var imgCookieLink = $.cookie("html_img");
$("html").css("background", "url('" + imgCookieLink + "') no-repeat fixed center top");
});
</script>
感谢tvanfosson的编辑:D – vache 2009-07-05 01:45:25
我不知道为什么背景颜色不会改变。但我强烈建议你尝试$(“body”).css(“background-color”,“#FF0000”),看看会发生什么。 – xandy 2009-07-05 14:51:18
$(“body”).css(“background-color”,“#FF0000”); 工作正常, – vache 2009-07-05 15:06:32