我想包括一個迷你菜單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