• 手机版

    扫码体验手机版

  • 微信公众号

    扫码关注公众号

国内首家协议开发

软芯音视解码保护平台

在线
客服

发布
需求

在线
聊天

天盟
APP

天盟APP下载

关注
微信

微信扫一扫访问
顶部

JavaScript事件练习问题

为什么鼠标滑过时颜色不改变?




   
    下拉菜单

     *{margin:0px;padding:0px;font:14px "微软雅黑" ;}
     #divselect ul li{list-style:none;}
     #divselect{width:200px;
                height:26px;
                position:relative;
                margin:80px auto;
                }
    #divselect cite{border:1px #666 solid;
                    line-height:26px;
                    width:180px;
                    height:26px;
                    display:block;
                    padding:0px 10px;
                    }
    #divselect ul{line-height:26px;
                  border:1px solid #666;
                  border-top:none;
                  width:200px;
                  display:none;}
    #divselect ul li{line-height:26px;
                    height:26px;}
    #divselect ul li a{text-decoration:none;
                        color:#333;
                        line-height:26px;
                        display:block;
                        padding:0px 10px;
                        width:180px;
                        }
    #divselect cite:before{
                      content:'';
                      position:absolute;
                      right: 8px;
                      bottom: 7px;
                      width:0px;
                      height:0px;
                      border-width:4px;
                      border-style: solid ;
                      border-color: #888 transparent transparent transparent;
                      transition: all 0.2s;
                      -webkit-transition: all 0.2s;
                      -moz-transition: all 0.2s;
                      -o-transition: all 0.2s;
                      -ms-transition: all 0.2s;
                      transform-origin: 50% 25%;
                      -ms-transform-origin: 50% 25%;
                      -moz-transform-origin: 50% 25%;
                      -webkit-transform-origin: 50% 25%;
                      -o-transform-origin: 50% 25%;
                        }

   <script type="text/javascript">
window.onload=function(){
    var box=document.getElementById('divselect')
        title=box.getElementsByTagName('cite')[0]
        menu=box.getElementsByTagName('ul')[0]
        select=box.getElementsByTagName('a')
        index=-1
        
        title.onclick=function(event){
            event=event || window.event;
            if(event.stopPropagation){
                event.stopPropagation();
            }
            else{
                event.cancelBubble=true;
            }
            menu.style.display='block';
                document.onkeyup=function(e){
                    e=e || window.event;
                    for(var i=0;i=select.length){
                            index=0;
                        }
                        select[index].style.background='#ccc'
                        }
                    //如果按下了向上方向键
                    if(e.keyCode==38){
                        

                        if(index

免责声明:本内容仅代表回答会员见解不代表天盟观点,请谨慎对待。

版权声明:作者保留权利,不代表天盟立场。

使用道具 举报

全部参与3

window.onload=function(){

另一半括号放到</script>前

for(var i=0;i

使用道具 举报

好像冒泡了

使用道具 举报

select是undefind,select是根据box得到的,box是局部变量吧

使用道具 举报

发新帖

发布任务需求已有1031166位用户正在使用天盟网服务

发布分类: *
任务预算: *
需求内容: *
手机号码: *
任务商家报价为
  • 预算价 :
  • 成交价 :
  • 完工期 :
  • 质保期 :

* 最终任务项目以服务商报价、双方协商为准!