<!doctype html><html>?<head>? <meta charset="UTF-8">?<style type="text/css">*{margin:0; padding:0;}#banner{width:730px; height:454px; margin:20px auto;position:relative; }#pic{width:730px; height:454px;}#pic img{position:absolute; top:0; left:0; display:none;}#left,#right{width:30px; height:40px; position:absolute; top:50%; margin-top:-20px;}#left{left:0px;}#right{right:0px;}#tab{width:160px; height:20px; position:absolute; left:50%; margin-left:-78px; bottom:10px;}#tab ul li{width:20px; height:20px; background:#bbb; color:#fff; text-align:center; line-height:20px; border-radius:100%; font-size:12px; font-family:"Microsoft yahei"; list-style:none; float:left; margin:0 3px; cursor:pointer;}#tab ul li.on{background:#f60;}?</style>? <title>定時(shí)輪播</title>?</head>?<body><div id="banner"><div id="pic"><img src="img/1.jpg" alt="" /><img src="img/2.jpg" alt="" /><img src="img/3.jpg" alt="" /><img src="img/4.jpg" alt="" /><img src="img/5.jpg" alt="" /><img src="img/6.jpg" alt="" /></div><div id="btn"><button id="left"><</button><button id="right">></button></div><div id="tab"><ul><li>1</li><li>2</li><li>3</li><li>4</li><li>5</li><li>6</li></ul></div></div><script type="text/javascript">var aImg=document.getElementById("pic").getElementsByTagName("img");var aTabli=document.getElementById("tab").getElementsByTagName("li");aImg[0].style.display="block";aTabli[3].className="on";for(var i=0;i<aTabli.length;i++;){aTabli[i].onclick=function(){for(var j=0;j<aTabli.length;j++;){aTabli[j].className="";}this.className="on";};}</script>?</body></html>
js里的li為什么獲取不了
qq_明_9
2016-10-23 20:30:20