在我的 HTML 页面中,我没有看到我的按钮...请帮助我...
#container
{
position:relative;
width:700px;
height:400px;
border: 2px solid black;
background-color:#888;
margin: 50px auto 0px;
overflow:hidden;
}
.box
{
position:relative;
width:600px;
height:300px;
border: 1px solid black;
margin: 50px auto 0px;
overflow:hidden;
}
#button
{
margin:47%;
position:absolute;
margin-top:2%;
}
JAVASCRIPT:
<script type="text/javascript">
var $c =0;
function next()
{
var boxes = document.getElementsByClassName("box");
$c +=1;
if($c >= boxes.length) $c = 0;
for (var $i=0;$i<boxes.length;$i++)
{
boxes[$i].style.display = "none";
}
boxes[$c].style.display = "block";
return false;
}
function prev()
{
var boxes = document.getElementsByClassName("box");
$c -=1;
if($c < 0) $c = (boxes.length-1);
for (var $i=0;$i<boxes.length;$i++)
{
boxes[$i].style.display = "none";
}
boxes[$c].style.display = "block";
return false;
}
</script>
HTML:
<div id="container">
<div class="box"><img src="img1.jpg"/></div>
<div class="box"><img src="img2.jpg"/></div>
<div class="box"><img src="img3.jpg"/></div>
<div id= button>
<button id="bwd" onclick="return prev()"><<</button>
<button id="fwd" onclick="return next()">>></button>
</div>
</div>