排他算法---应用于轮播图小圆点

//===============排他算法(应用轮播图小圆点)===========
        var opp = document.getElementById("box1").getElementsByTagName("p");

        //for循环为每个小圆点添加监听
        for(var i=0;i<=opp.length;i++){

            //绑定onmouseover事件
            opp[i].onmouseover=function(){

                //先把所有的小圆点变为灰色
                for(var j=0;j<opp.length;j++){

                    opp[j].style.backgroundColor="#ccc";

                }
                //再让自己变红
                this.style.backgroundColor="red";
            }
        }

 

posted @ 2018-08-27 01:27  码到攻城  阅读(289)  评论(0编辑  收藏  举报