我是一个 jQuery 初学者,我一直在根据我最近看到的一些教程构建一个内容滑块。
问题是:我不知道如何构建一个子弹导航来完成它。
到目前为止,这是我的代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>My content slider</title>
<style type="text/css">
body {
margin: 0 0 0 0;
}
.slider {
width: 100%;
height: 400px;
overflow: hidden;
}
.slider div {
width: 100%;
height: 400px;
display: none;
}
.img {
width: 100%;
height: 400px;
}
h1 {
text-align: center;
color:#F00;
margin: auto;
padding-top: 45px;
}
</style>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js"></script>
<script type="text/javascript">
function Slider() {
$(".slider #1").show("fade", 500);
$(".slider #1").delay(5500)
.hide("slide", {direction: "left"}, 500);
var sc=$(".slider div").size();
var count=2;
setInterval(function (){
$(".slider #"+count).show("slide", {direction: "right"}, 500);
$(".slider #" + count).delay(5500).hide("slide", {direction: "left"}, 500);
if(count==sc){
count=1;
} else {
count = count + 1;
}
}, 6500);
}
</script>
</head>
<body onload="Slider();">
<div class="slider">
<div class="img" id="1" style="background-color:#0F0;">
<h1>My text is here</h1>
</div>
<div class="img" id="2" style="background-color:#000;">
<h1>My text is here</h1>
</div>
<div class="img" id="3" style="background-color:#FF0;">
<h1>My text is here</h1>
</div>
</div>
</body>
</html>
请有人帮我解决这个问题吗?
提前致谢!