为什么出错了
显示getElementsByTagName错误
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>综合实例</title>
<link rel="stylesheet" type="text/css" href="css/lunbo.css">
</head>
<body>
<div class="main" id="main">
<div class="banner" id="banner">
<a href="">
<div class="banner-slide slide1 slide-active"></div>
</a>
<a href="">
<div class="banner-slide slide2"></div>
</a>
<a href="">
<div class="banner-slide slide3"></div>
</a>
</div>
<!--上一张、下一张按钮-->
<a href="" class="button prev"></a>
<a href="" class="button next"></a>
<!--圆点导航-->
<div class="dots">
<span class="active"></span>
<span></span>
<span></span>
</div>
</div>
<script type="text/javascript" src="js/javascript.js"></script>
</body>
</html>
*{
margin: 0;
padding: 0;
}
ul{
list-style: none;
}
body{
font-family: "微软雅黑";
color: #14191e;
}
.main{
width: 1200px;
height: 460px;
margin: 30px auto;
overflow: hidden;
position: relative;
}
.banner{
width: 1200px;
height: 460px;
overflow: hidden;
position: relative;
}
.banner-slide{
width: 1200px;
height: 460px;
background-repeat: no-repeat;/*图片只显示一次*/
position: absolute;
display: none;
}
.slide1{
background-image: url(../img/bg1.jpg);
}
.slide2{
background-image: url(../img/bg2.jpg);
}
.slide3{
background-image: url(../img/bg3.jpg);
}
.slide-active{
display: block;
}
.button{
position: absolute;
width: 40px;
height: 80px;
left: 244px;
top: 50%;
margin-top: -40px;
background: url(../img/arrow.png) no-repeat center center;
}
.button:hover{
background-color: #333;/*background-color只改变背景颜色不改变已有的背景*/
opacity: 0.8;
filter: alpha(opacity=0.8);
}
.prev{
transform: rotate(180deg);
}
.next{
left:auto;
right: 0px;
}
.dots{
position: absolute;
bottom: 24px;
right: 20px;
text-align: right;
}
.dots span{
display: inline-block;/*让圆点水平方向排列*/
height: 12px;
width: 12px;
line-height: 12px;/*居中对齐*/
border-radius: 50%;
background: rgba(7,17,27,0.4);
box-shadow: 0 0 0 2px rgba(255,255,255,0.8)inset;/*设置锚边*/
margin-left: 8px;
cursor: pointer;/*让光标变为手型*/
}
.dots span .active{
box-shadow: 0 0 0 2px rgba(7,17,27,0.4)inset;
background: #fff;
}
function byId(id) {
return typeof(id) === "String" ? document.getElementById(id) : id;
}
var index = 0;
var timer = null;
pics=byId("banner").getElementsByTagName("div");
len=pics.length;
console.log(len);
function slideImg() {
var main = byId("main");
main.onmouseover = function() {
//滑过清除定时器
}
main.onmouseout = function() {
timer = setInterval(function() {
index++;
console.log(index);
}, 3000);
}
}
slideImg();
正在回答 回答被采纳积分+1
- 参与学习 人
- 提交作业 676 份
- 解答问题 9666 个
本阶段将从前端网页搭建入手,到Java Web基础,前后端结合助你完成Java Web小白的蜕变!
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星