HOW TO MAKE SIMPLE JQUERY SLIDER
HTML
<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
<head>
<title>Slider</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="style/newcss.css"/>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("#btn1").click(function(){
$("#one").animate({width:'1080px',height:'500px'},600);
$("#two").animate({width:'0px',height:'500px',left:'135px'},600);
$("#three").animate({width:'0px',height:'500px',left:'135px'},600);
$("#four").animate({width:'0px',height:'500px',left:'135px'},600);
$("#five").animate({width:'0px',height:'500px',left:'135px'},600);
$("#six").animate({width:'0px',height:'500px',left:'135px'},600);
$("#seven").animate({width:'0px',height:'0px',left:'1214px'},600);
$("#btn1").hide();
$("#btn2").show();
$("#btn3").hide();
$("#btn4").hide();
$("#btn5").hide();
$("#btn6").hide();
$("#btn7").hide();
});
$("#btn2").click(function(){
$("#btn1").hide();
$("#btn2").hide();
$("#btn3").show();
$("#btn4").hide();
$("#btn5").hide();
$("#btn6").hide();
$("#btn7").hide();
$("#one").animate({width:'0px',height:'0px',left:'1214px',top:'500px'},600);
$("#two").animate({width:'1080px',height:'500px'},600);
$("#three").animate({width:'0px',height:'500px',left:'135px'},600);
$("#four").animate({width:'0px',height:'500px',left:'135px'},600);
$("#five").animate({width:'0px',height:'500px',left:'135px'},600);
$("#six").animate({width:'0px',height:'500px',left:'135px'},600);
$("#seven").animate({width:'0px',height:'500px',left:'135px'},600);
});
$("#btn3").click(function(){
$("#btn1").hide();
$("#btn2").hide();
$("#btn3").hide();
$("#btn4").show();
$("#btn5").hide();
$("#btn6").hide();
$("#btn7").hide();
$("#one").animate({width:'0px',height:'500px',left:'135px'},600);
$("#two").animate({width:'0px',height:'0px',left:'1214px',top:'0px'},600);
$("#three").animate({width:'1080px',height:'500px'},600);
$("#four").animate({width:'0px',height:'500px',left:'135px'},600);
$("#five").animate({width:'0px',height:'500px',left:'135px'},600);
$("#six").animate({width:'0px',height:'500px',left:'135px'},600);
$("#seven").animate({width:'0px',height:'500px',left:'135px'},600);
});
$("#btn4").click(function(){
$("#btn1").hide();
$("#btn2").hide();
$("#btn3").hide();
$("#btn4").hide();
$("#btn5").show();
$("#btn6").hide();
$("#btn7").hide();
$("#one").animate({width:'0px',height:'500px',left:'135px'},600);
$("#two").animate({width:'0px',height:'500px',left:'135px'},600);
$("#three").animate({width:'0px',height:'0px',left:'607px',top:'500px'},600);
$("#four").animate({width:'1080px',height:'500px'},600);
$("#five").animate({width:'0px',height:'500px',left:'135px'},600);
$("#six").animate({width:'0px',height:'500px',left:'135px'},600);
$("#seven").animate({width:'0px',height:'500px',left:'135px'},600);
});
$("#btn5").click(function(){
$("#btn1").hide();
$("#btn2").hide();
$("#btn3").hide();
$("#btn4").hide();
$("#btn5").hide();
$("#btn6").show();
$("#btn7").hide();
$("#one").animate({width:'0px',height:'500px',left:'135px'},600);
$("#two").animate({width:'0px',height:'500px',left:'135px'},600);
$("#three").animate({width:'0px',height:'500px',left:'135px'},600);
$("#four").animate({width:'0px',height:'500px',left:'1214px'},600);
$("#five").animate({width:'1080px',height:'500px'},600);
$("#six").animate({width:'0px',height:'500px',left:'135px'},600);
$("#seven").animate({width:'0px',height:'500px',left:'135px'},600);
});
$("#btn6").click(function(){
$("#btn1").hide();
$("#btn2").hide();
$("#btn3").hide();
$("#btn4").hide();
$("#btn5").hide();
$("#btn6").hide();
$("#btn7").show();
$("#one").animate({width:'0px',height:'500px',left:'135px'},600);
$("#two").animate({width:'0px',height:'500px',left:'135px'},600);
$("#three").animate({width:'0px',height:'500px',left:'135px'},600);
$("#four").animate({width:'0px',height:'500px',left:'135px'},600);
$("#five").animate({width:'0px',height:'500px',left:'1214px'},600);
$("#six").animate({width:'1080px',height:'500px'},600);
$("#seven").animate({width:'0px',height:'500px',left:'135px'},600);
});
$("#btn7").click(function(){
$("#btn1").show();
$("#btn2").hide();
$("#btn3").hide();
$("#btn4").hide();
$("#btn5").hide();
$("#btn6").hide();
$("#btn7").hide();
$("#one").animate({width:'0px',height:'500px',left:'135px'},600);
$("#two").animate({width:'0px',height:'500px',left:'135px'},600);
$("#three").animate({width:'0px',height:'500px',left:'135px'},600);
$("#four").animate({width:'0px',height:'500px',left:'135px'},600);
$("#five").animate({width:'0px',height:'500px',left:'135px'},600);
$("#six").animate({width:'0px',height:'500px',left:'1214px'},600);
$("#seven").animate({width:'1080px',height:'500px'},600);
});
});
</script>
</head>
<body>
<button id="btn7">seven</button>
<button id="btn6">six</button>
<button id="btn5">five</button>
<button id="btn4">four</button>
<button id="btn3">three</button>
<button id="btn2">two</button>
<button id="btn1">one</button>
<div id="cover">
<div id="one"></div>
<div id="two"></div>
<div id="three"></div>
<div id="four"></div>
<div id="five"></div>
<div id="six"></div>
<div id="seven"></div>
</div>
<script>
do {
s += 1;
document.write(s);
} while (s < 5);
</script>
</body>
</html>
CSS
body
{
margin: 0px;
background: url('slide2.jpg')no-repeat;
}
#cover
{
height: 500px;
width: 1080px;
margin: auto;
overflow: hidden;
}
#one
{
height: 500px;
width: 0px;
position: absolute;
background:pink;
left: 135px;
background: url(../images/slide8.jpg)no-repeat;
}
#two
{
height: 500px;
width: 0px;
position: absolute;
background:green;
left: 135px;
background: url(../images/slide2.jpg)no-repeat;
}
#three
{
height: 500px;
width: 0px;
position: absolute;
background:red;
left: 135px;
background: url(../images/slide3.jpg)no-repeat;
}
#four
{
height: 500px;
width: 0px;
position: absolute;
background:yellowgreen;
left: 135px;
background: url(../images/slide4.jpg)no-repeat;
}
#five
{
height: 500px;
width: 0px;
position: absolute;
background:purple;
left: 135px;
background: url(../images/slide5.jpg)no-repeat;
}
#six
{
height: 500px;
width: 0px;
position: absolute;
background:orangered;
left: 135px;
background: url(../images/slide6.jpg)no-repeat;
}
#seven
{
height: 500px;
width: 0px;
position: absolute;
background:blue;
left: 135px;
background: url(../images/slide7.jpg)no-repeat;
}
#btn1
{
position: absolute;
}
#btn2
{
position: absolute;
}
#btn3
{
position: absolute;
}
#btn4
{
position: absolute;
}
#btn5
{
position: absolute;
}
#btn6
{
position: absolute;
}
#btn7
{
position: absolute;
}
Comments
Post a Comment