为了账号安全,请及时绑定邮箱和手机立即绑定

急求急求,怎么轮播小圆点按钮点击的位置改变不了

急求急求,怎么轮播小圆点按钮点击的位置改变不了

qq_10_11 2017-04-09 21:03:06
<!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8">    <title>Title</title>    <style> * {            margin: 0; padding: 0; list-style: none; }        .box {            width: 490px; height: 170px; border: 1px solid #000000; margin: 100px auto; padding: 5px; position: relative; }        .box .slider{            width: 100%; height: 100%; }        .box .slider ul{            width: 100%; height: 100%; position: absolute; left: 5px; bottom: 0px; }        .box .slider li{            position: absolute; top:5px; left: 490px; }        .box ol{            text-align: center; }        .box ol .btn{            width: 20px; height: 20px; border-radius:50%; background: #cccccc; display: inline-block; margin: 0 5px; cursor: pointer; overflow: hidden; }        .box ol .btn.cur{            background: red; }    </style></head><body><div class="box">    <div class="slider">        <ul>            <li><img src="images/01.jpg" alt=""></li>            <li><img src="images/02.jpg" alt=""></li>            <li><img src="images/03.jpg" alt=""></li>            <li><img src="images/04.jpg" alt=""></li>            <li><img src="images/05.jpg" alt=""></li>        </ul>    </div>    <ol> <!--<li class="btn cur"></li>        <li class="btn "></li>        <li class="btn "></li>        <li class="btn "></li>        <li class="btn "></li>--> </ol></div></body></html><script src="gd.js"></script><script> var obox=document.querySelector(".box"); var slider=obox.querySelector(".slider"); var ali=slider.children[0].querySelectorAll("li"); var oOl=obox.querySelector("ol"); var oli=obox.children[1].children; init(); a(); //生成圆点 function init() {        for (var i=0;i<ali.length;i++)        {            var oli= document.createElement("li"); //oli.innerHTML= oli.length;添加文本 oOl.insertBefore(oli,oOl.children[0]); oli.setAttribute("class","btn")        }        oOl.children[0].className="btn cur"; ali[0].style.left= "0px"; }    //轮播 function a() {            oli.onclick=function(){                                for(var i=0;i<oli.length;i++)                {                    oli[i].className = "btn"; }                oli[i].className = "btn cur"; }    }</script>
查看完整描述

1 回答

已采纳
?
千秋此意

TA贡献158条经验 获得超187个赞

function a() {
    for (var i = 0; i < oli.length; i++) {
        oli[i].onclick = function(iNow) {
            return function() {
                for (var i = 0; i < oli.length; i++) {
                    oli[i].className = "btn";
                }
                oli[iNow].className = "btn cur";
            }
        }(i);
    }
}

函数a这样写小圆点就能动了(没素材其他地方我没改)

查看完整回答
2 反对 回复 2017-04-09
?
慕瓜9220888

TA贡献868条经验 获得超0个赞

VQFQCVLDD

NRPUMPVIS

MDIHZYBUK

LGWMJGSSC

FUJPELOEF

ETPHPZWJX

DTRAYEXGJ

PIRQOYVOH

ECEKAJJCG

SMYQIIBRH

YPECLKTGW

TBWBGTJMP

KTPKSVFBB

ITVHSPBIE

KIBTCZIVS

ZAIXYSIOB

HIGHFIBEY

VWKJUBNXU

XFXFRBUHA

UBRGVHQNJ

NKPBWCSFO

EPKGOHALB

SPYIXTTZA

ZAWRTCJSG

RPKCOUEYS

RORXGNKBZ

EIESEEAQQ

XEJBGZYHZ

LZRSKGWWS

TONSDNQCM

MBGHJCMWZ

FXVTPLZCP

OZHWSZCBO

YPKJONNDT

ABQYMILYL

DODXMVBKD

ZLGYQADJQ

GDMAPIRBE

ZNPNWMCVY

WDCEZWANT

RCXWYHKXK

SNLDFCSLO

LCAMNXWMV

BCGFBOTPP

ODMUIIORK

LZVNSJNJW

ALDNBIRRU

UIACAUUGD

WRTMYVMTG

NAQFDEHDR

TXDTVULRC

LZIHZMZMQ

GRTCAXGKR

IXQEJQZSV

QIHMBTSBH

ETEWIXRNX

LTVAYIOHQ

JHNPHGATS

ECMRJDFIS

JKDRZJZSE

EDIOMQUOK

XVIGIIKUK

CNFNPEXAJ

DSXPAEAAK

JUMYDAZMV

JDMNMSDWM

WOCRTQZCL

BMKFHQKMQ

HBNIUKWWJ

WOAOHIYKE

UPHTPMPIH

LCKENWIBO

ZYTVNTMZP

IGXPIHRAQ

DUJWEDNMG

ECUPXQMMP

XMKPLEAXG

QEMUMOXNQ

XOTSXQFYS

ZNMUCMBBR

NRMKPPOHY

ASELCNXEG

VHPRHKKQK

SJGIRROFV

OPPBMWVBC

MRDSOVVYP

NENOJQGZI

JKIRWPEWJ

KGYWBLUTA

PWVJVUUND

ECACBYLBT

QUJHYHQWM

NYMVTCZCE

IPOQIRRXH

IPXPEHWJE

DODBQWFSR

EVTSKTWYR

TNCNBVKKK

KSJSDGPJC

HUTIXQJCK

ARWUWJATJ

ZNLKFBLUH

GQWVGWMVS

TUJRZPOBM

DNCRPFWPG

QOWKCZTZJ

ITIOTXUAB

JUCABKDXD

TRZHXXQZG

YVXCAWSPS

XEMUMCIBB

XVALBERAN

UBTIUPVSR

OLKSQJPSZ

AIQONDVFY

DHJECVEKH

STSDDTCCP

GFKLGPVVR

PGOXLREDD

NBTBZJVYI

ZHVNPBKMV

NKJXPIKDM

PINSZLRKN

AGOXVVKEH

QUSATCFEY

LMHFUJMCY

YMUMLYORD

OVKOXWZPO

CJBWSJZIL

FACHDQXKO

XBWVTMWZI

RPNUIVREB

VJBGRXXGD

WAIGVONTJ

PKMKJFSLU

JGYQYYGZP

PWOVDDMFV

FWELJTCIF

EYKNCFEYH

TEJTBXHQG

DVAPVSVVM

OPESHUNAF

TKSHPVYYR

LJEMEWYOO

OSFUCFVYL

VTYWSVREF

MDCHVSBBB

YGBMYBAQZ

WKIUICRLT

ICXZYXXGV

XLJONGPYN

RSRPLRZLO

QOWVJZUXQ

RLKPNNCPM

HIQFNNMWZ

LCRTCVENA

DNLAZSRBN

KUPLMFVNZ

AKTHCOAWW

BKSAGZOYU

MQSQFVMJS

JHMVKTMFF

BMECHKQTT

HXMOGWZYB

PDVDISLUK

TKQENWORK

PNECLUDAQ

MQJUMFPOE

PGIDBLWFS

EHTRMPVOL

NUAONMGZC

NEGBATSYR

ITFKFPFRR

WTJVYUYLM

LJYQSRBNQ

VRJHQMCLY

OVRJYEXWZ

DLNRQTJLL

FDFRPSLEX

KSAZANDUR

查看完整回答
反对 回复 2021-10-19
  • 1 回答
  • 0 关注
  • 2341 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信