潜在的な背景の20pxx20pxの画像のミニメニューを含めたいと思います。ユーザーがそれらの1つをクリックすると、ボディの背景画像が変更され、選択内容がユーザーの選択として保存されます。
li
スライダーを使用することを考えましたが、どのように画像をaに入れ、選択に基づいて本体のCSSを変更できるかわかりません。
何か案は?
ハッピー7月4日
編集私はそのクッキーにimgURLを保存しようとしています、それは機能していません、それはクッキーに保存していますが、クッキーの内容を取得していません
以下の作品を編集してください、!!!!!!! しかし、私が追加しても背景色は常に白です $("html").css("background-color","red");
修正、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>