第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

JavaScript事件練習(xí)問題

JavaScript事件練習(xí)問題

kx00012kx 2016-08-04 16:35:45
為什么鼠標(biāo)滑過時顏色不改變?<!doctype html><html><head>? ? <meta charset="UTF-8">? ? <title>下拉菜單</title><style type="text/css">? ? ?*{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%;? ? ? ? ? ? ? ? ? ? ? ? }</style>? ?<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;i++){? ? ? ? ? ? ? ? ? ? ? ? select[i].style.background='#ccc'? ? ? ? ? ? ? ? ? ? }? ? ? ? ? ? ? ? ? ? //如果按下了向下方向鍵? ? ? ? ? ? ? ? ? ? if(e.keyCode==40){? ? ? ? ? ? ? ? ? ? ? ? index++? ? ? ? ? ? ? ? ? ? ? ? if(index>=select.length){? ? ? ? ? ? ? ? ? ? ? ? ? ? index=0;? ? ? ? ? ? ? ? ? ? ? ? }? ? ? ? ? ? ? ? ? ? ? ? select[index].style.background='#ccc'? ? ? ? ? ? ? ? ? ? ? ? }? ? ? ? ? ? ? ? ? ? //如果按下了向上方向鍵? ? ? ? ? ? ? ? ? ? if(e.keyCode==38){? ? ? ? ? ? ? ? ? ? ? ??? ? ? ? ? ? ? ? ? ? ? ? if(index<=0){? ? ? ? ? ? ? ? ? ? ? ? ? ? index=select.length? ? ? ? ? ? ? ? ? ? ? ? ? ??? ? ? ? ? ? ? ? ? ? ? ? }? ? ? ? ? ? ? ? ? ? ? ? index--? ? ? ? ? ? ? ? ? ? ? ? select[index].style.background='#ccc'? ? ? ? ? ? ? ? ? ? }? ? ? ? ? ? ? ? ? ? //如果按下了回車鍵? ? ? ? ? ? ? ? ? ? if(e.keyCode==13 && index!=-1){? ? ? ? ? ? ? ? ? ? ? ? title.innerHTML=select[index].innerHTML;? ? ? ? ? ? ? ? ? ? ? ? for(var i=0;i<select.length;i++){? ? ? ? ? ? ? ? ? ? ? ? ? ? select[i].style.background='none'? ? ? ? ? ? ? ? ? ? ? ? }? ? ? ? ? ? ? ? ? ? ? ??? ? ? ? ? ? ? ? ? ? ? ? menu.style.display='none';? ? ? ? ? ? ? ? ? ? ? ? index=-1;? ? ? ? ? ? ? ? ? ? }? ? ? ? ? ? ? ? } ??? ? ? ? }? ? ? ??}? ? ? ? //滑過滑過、離開、點擊每個選項時? ? ? ??? ? for(var i=0;i<select.length;i++){? ? ? ? select[i].onmouseover=function(){? ? ?this.style.background='#ccc';? ? ?}? ? ?select[i].onmouseout=function(){? ? ?this.style.background='none';? ? ?}?? ? ? ? select[i].onclick=function(){? ? ? ? ? ? title.innerHTML=this.innerHTML;? ? ? ? ? ? menu.style.display='none'? ? }}//點擊空白處時document.onclick=function(){? ? menu.style.display='none'}? ?</script></head><body><div id="divselect">? ? ? <cite>請選擇分類</cite>? ? ? <ul>? ? ? ? ?<li id="li"><a href="javascript:;" selectid="1">ASP開發(fā)</a></li>? ? ? ? ?<li><a href="javascript:;" selectid="2">.NET開發(fā)</a></li>? ? ? ? ?<li><a href="javascript:;" selectid="3">PHP開發(fā)</a></li>? ? ? ? ?<li><a href="javascript:;" selectid="4">Javascript開發(fā)</a></li>? ? ? ? ?<li><a href="javascript:;" selectid="5">Java特效</a></li>? ? ? </ul>? ? </div></body></html>
查看完整描述

3 回答

已采納
?
慕粉3456840

TA貢獻(xiàn)16條經(jīng)驗 獲得超4個贊


window.onload=function(){?

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

for(var i=0;i<select.length;i++){

?select[i].style.background='none';
? }這里也改一下,顏色改為none



查看完整回答
1 反對 回復(fù) 2016-08-04
?
田心楓

TA貢獻(xiàn)1064條經(jīng)驗 獲得超383個贊

好像冒泡了

查看完整回答
1 反對 回復(fù) 2016-08-04
  • kx00012kx
    kx00012kx
    我自己又檢查了一遍,發(fā)現(xiàn)是因為“//滑過滑過、離開、點擊每個選項時”這段代碼沒放在window.onload=function(){。。。。}里面,所以無效了。 謝謝
?
一杯2塊的奶茶

TA貢獻(xiàn)226條經(jīng)驗 獲得超75個贊

select是undefind,select是根據(jù)box得到的,box是局部變量吧

查看完整回答
反對 回復(fù) 2016-08-04
  • 3 回答
  • 0 關(guān)注
  • 1799 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號