一直在寻找改变点击内容的滑块的年龄,这正是我想要做的:
但由于某种原因,我无法让它工作。我已经从 jsfiddle 页面复制了代码,但它不起作用。我可能搞砸了一些超级基本的东西,但这是我的代码:)
<style>
body {
padding: 0px;
}
#container {
position: absolute;
margin: 0px;
padding: 0px;
width: 100%;
height: 100%;
overflow: hidden;
}
.box {
position: absolute;
width: 50%;
height: 300px;
line-height: 300px;
font-size: 50px;
text-align: center;
border: 2px solid black;
left: 50%;
top: 100px;
margin-left: -25%;
}
#box1 {
background-color: green;
left: -50%;
}
#box2 {
background-color: yellow;
}
#box3 {
background-color: red;
left: 150%;
}
#box4 {
background-color: orange;
left: 150%;
}
#box5 {
background-color: blue;
left: 150%;
}
</style>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.4.js"></script>
</head>
<body>
<script type="text/javascript">
$('.box').click(function() {
$('.box').each( function() {
if ($(this).offset().left < 0) {
$(this).css("left", "150%");
}
});
$(this).animate({
left: '-50%'
}, 500);
if ($(this).next().size() > 0) {
$(this).next().animate({
left: '50%'
}, 500);
} else {
$(this).prevAll().last().animate({
left: '50%'
}, 500);
}
});j
</script>
<div id="container">
<div id="box1" class="box">Div #1</div>
<div id="box2" class="box">Div #2</div>
<div id="box3" class="box">Div #3</div>
<div id="box4" class="box">Div #4</div>
<div id="box5" class="box">Div #5</div>
</div>