潜在的な背景の20pxから20pxのミニメニューを追加したいと思います。 ユーザーが1つをクリックすると、本体の背景イメージが変更され、その選択がユーザーの選択として保存されます。jqueryスライダーで体の背景を変更する
私はスライダーを使用することを考えましたが、li
の画像をどのように持つことができず、選択に基づいてボディCSSを変更できるようになるかわかりません。
アイデア?
ハッピー7月4日
EDIT 私は以下、そのクッキーにIMGのURLを保存するために、その動作していないカントー、クッキーでの節約が、そのクッキーのコンテンツを取得しませ
EDIT をしようとしています作品、!!!!!!!しかし、背景色は常に白である私は を追加した場合でも$("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
背景色が変更されない理由はわかりません。しかし、私はあなたに$( "body").css( "background-color"、 "#FF0000")を試してみることを強くお勧めします。 – xandy
$( "body")。css( "背景色"、 "#FF0000"); 正常に動作し、 – vache