Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 如何在单击按钮时更改我的网站背景?_Jquery_Css - Fatal编程技术网

Jquery 如何在单击按钮时更改我的网站背景?

Jquery 如何在单击按钮时更改我的网站背景?,jquery,css,Jquery,Css,我得到了一个窗帘式的网站,前面和后面的窗帘和前面的窗帘。当我点击主页和我们周围的按钮时,我的连续后窗帘图像应该会改变。请帮我解决这个问题。到目前为止,我的代码如下: <script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.js"></script> <script src="jquery.easing.1.3.js" type="text/ja

我得到了一个窗帘式的网站,前面和后面的窗帘和前面的窗帘。当我点击主页和我们周围的按钮时,我的连续后窗帘图像应该会改变。请帮我解决这个问题。到目前为止,我的代码如下:

<script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.js"></script>
    <script src="jquery.easing.1.3.js" type="text/javascript"></script>  

    <script type="text/javascript">
        $(document).ready(function() {

            $curtainopen = false;

            $(".hrope").click(function(){

                $(this).blur();
                if ($curtainopen == false){ 
                    $(this).stop().animate({top: '0px' }, {queue:false, duration:350, easing:'easeOutBounce'}); 
                    $(".leftcurtain").stop().animate({width:'60px'}, 2000 );
                    $(".rightcurtain").stop().animate({width:'60px'},2000 );
                    $curtainopen = true;


                }else{
                    $(this).stop().animate({top: '-40px' }, {queue:false, duration:350, easing:'easeOutBounce'}); 
                    $(".leftcurtain").stop().animate({width:'50%'}, 2000 );
                    $(".rightcurtain").stop().animate({width:'51%'}, 2000 );
                    $curtainopen = false;

                }
                return false;

            });

        }); 
        $(document).ready(function() {

            $curtainopen = false;

            $(".arope").click(function(){
                $(this).blur();
                if ($curtainopen == false){ 
                    $(this).stop().animate({top: '0px' }, {queue:false, duration:350, easing:'easeOutBounce'}); 
                    $(".leftcurtain").stop().animate({width:'60px'}, 2000 );
                    $(".rightcurtain").stop().animate({width:'60px'},2000 );
                    $curtainopen = true;
                }else{
                    $(this).stop().animate({top: '-40px' }, {queue:false, duration:350, easing:'easeOutBounce'}); 
                    $(".leftcurtain").stop().animate({width:'50%'}, 2000 );
                    $(".rightcurtain").stop().animate({width:'51%'}, 2000 );
                    $curtainopen = false;
                }
                return false;

            });

        }); 
        $(document).ready(function() {

            $curtainopen = false;

            $(".crope").click(function(){
                $(this).blur();
                if ($curtainopen == false){ 
                    $(this).stop().animate({top: '0px' }, {queue:false, duration:350, easing:'easeOutBounce'}); 
                    $(".leftcurtain").stop().animate({width:'60px'}, 2000 );
                    $(".rightcurtain").stop().animate({width:'60px'},2000 );

                    $curtainopen = true;

                }else{
                    $(this).stop().animate({top: '-40px' }, {queue:false, duration:350, easing:'easeOutBounce'}); 
                    $(".leftcurtain").stop().animate({width:'50%'}, 2000 );
                    $(".rightcurtain").stop().animate({width:'51%'}, 2000 );
                    $curtainopen = false;

                }
                return false;

            });

        });

    </script>

    <style type="text/css">
        *{
            margin:0;
            padding:0;
        }
        body{  
    text-align: center;
    background: #4f3722 url('images/darkcurtain.jpg') repeat-x;
    background: #4f3722 url('images/home.png') repeat-x;;
            }
        .div{           
            background-image:url('images/home.png') repeat-x;
        }


        img{
            border: none;
        }
        .leftcurtain{
            width: 50%;
            height: 495px;
            top: 0px;
            left: 0px;
            position: absolute;
            z-index: 2;
        }
         .rightcurtain{
            width: 51%;
            height: 495px;
            right: 0px;
            top: 0px;
            position: absolute;
            z-index: 3;
        }
        .rightcurtain img, .leftcurtain img{
            width: 100%;
            height: 100%;
        }
        .logo{
            margin: 0px auto;
            margin-top: 150px;
        }
        .hrope{
            position:absolute;
            top:5px;

            left: 70%;
            z-index:4;
        }
        .arope{
            position: absolute;
            top:5px;

            left: 80%;
            z-index:4;

        }
        .crope{
            position: absolute;
            top:5px;

            left: 90%;
            z-index:4;
        }



    </style>

</head>

<body>
    <div class="leftcurtain"><img src="images/frontcurtain.jpg"/></div>
    <div class="rightcurtain"><img src="images/frontcurtain.jpg"/></div>
    <img class="logo" src="images/buildinter.jpg"; />
    <a class="hrope" href="#">
        <img src="images/hrope.png"/>

    </a>
    <a class="arope" href="#">
        <img src="images/arope.png"/>
    </a>
    <a class="crope" href="#">
        <img src="images/crope.png"/>
    </a>

</body>

$(文档).ready(函数(){
$curtainopen=false;
$(“.hrope”)。单击(函数(){
$(this.blur();
如果($curtainopen==false){
$(this.stop().animate({top:'0px'},{queue:false,duration:350,easeOutBounce'});
$(“.left窗帘”).stop().animate({width:'60px'},2000);
$(“.Right窗帘”).stop().animate({width:'60px'},2000);
$curtainopen=true;
}否则{
$(this.stop().animate({top:'-40px'},{queue:false,duration:350,easeOutBounce'});
$(“.left窗帘”).stop().animate({width:'50%”,2000);
$(“.Right窗帘”).stop().animate({width:'51%},2000);
$curtainopen=false;
}
返回false;
});
}); 
$(文档).ready(函数(){
$curtainopen=false;
$(“.arope”)。单击(函数(){
$(this.blur();
如果($curtainopen==false){
$(this.stop().animate({top:'0px'},{queue:false,duration:350,easeOutBounce'});
$(“.left窗帘”).stop().animate({width:'60px'},2000);
$(“.Right窗帘”).stop().animate({width:'60px'},2000);
$curtainopen=true;
}否则{
$(this.stop().animate({top:'-40px'},{queue:false,duration:350,easeOutBounce'});
$(“.left窗帘”).stop().animate({width:'50%”,2000);
$(“.Right窗帘”).stop().animate({width:'51%},2000);
$curtainopen=false;
}
返回false;
});
}); 
$(文档).ready(函数(){
$curtainopen=false;
$(“.crope”)。单击(函数(){
$(this.blur();
如果($curtainopen==false){
$(this.stop().animate({top:'0px'},{queue:false,duration:350,easeOutBounce'});
$(“.left窗帘”).stop().animate({width:'60px'},2000);
$(“.Right窗帘”).stop().animate({width:'60px'},2000);
$curtainopen=true;
}否则{
$(this.stop().animate({top:'-40px'},{queue:false,duration:350,easeOutBounce'});
$(“.left窗帘”).stop().animate({width:'50%”,2000);
$(“.Right窗帘”).stop().animate({width:'51%},2000);
$curtainopen=false;
}
返回false;
});
});
*{
保证金:0;
填充:0;
}
正文{
文本对齐:居中;
背景:#4f3722 url('images/darkcurtain.jpg')repeat-x;
背景:#4f3722 url('images/home.png')repeat-x;;
}
.div{
背景图片:url('images/home.png')repeat-x;
}
img{
边界:无;
}
.左窗帘{
宽度:50%;
身高:495px;
顶部:0px;
左:0px;
位置:绝对位置;
z指数:2;
}
.右窗帘{
宽度:51%;
身高:495px;
右:0px;
顶部:0px;
位置:绝对位置;
z指数:3;
}
.右帘式仪表图、.左帘式仪表图{
宽度:100%;
身高:100%;
}
.标志{
保证金:0px自动;
边缘顶部:150px;
}
霍洛普先生{
位置:绝对位置;
顶部:5px;
左:70%;
z指数:4;
}
阿罗佩先生{
位置:绝对位置;
顶部:5px;
左:80%;
z指数:4;
}
克罗普先生{
位置:绝对位置;
顶部:5px;
左:90%;
z指数:4;
}
在jsfiddle上试试这个


改变
#变革{
宽度:200px;
高度:200px;
}
瑞德先生{
背景:红色;
}
蓝先生{
背景:蓝色;
}
$(文档).ready(函数(){
$('a')。单击(函数(){
$(“#changeme”).toggleClass('red-blue');
});
});

。。。
$(“更改”)。单击(函数(){
$(“#body”).css(“背景色”、“红色”)
});

tl;博士,请在你认为需要帮助的地方张贴你的具体问题和具体部分。我想在点击按钮时更改我的背景(不是按钮的背景)。。。
<html>
<head>
    <title>Change</title>
    <script type="text/javascript" src="jquery-1.7.1.min.js"></script>
    <style type="text/css">

        #changeme {
            width: 200px;
            height: 200px;
        }
        .red {
            background: red;
        }
        .blue {
            background: blue;
        }
    </style>
    <script type="text/javascript">
        $(document).ready(function(){
            $('a').click(function() {
                $('#changeme').toggleClass('red blue');
            });
        });
    </script>
</head>
<body>
    <div id="changeme" class="red"></div>
    <a id="button" href="#">Change Background Color</a>
</body>
...
<body>
 <div id="body">
  <a id="Change" href=#>ChangeBackground</a>
 </div>
</body>

<script>
 $("Change").click(function () {
  $("#body").css("background-color","red")
 });

</script>