課程
/前端開發(fā)
/JavaScript
/DOM事件探秘
請問這個有源碼嗎?還有各種圖片,在哪里可以下載到
2017-03-06
源自:DOM事件探秘 4-1
正在回答
視頻的右下角,有“資料下載”下面的“源碼”右面的“下載”就可以下載了?。?/p>
window.onload=function(){ ? ?var box=document.getElementById('divselect'), ? ? ? ? ? ?title=box.getElementsByTagName('cite')[0], ? ? ? ? ? ?menu=box.getElementsByTagName('ul')[0], ? ? ? ? ? ?as=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<as.length;i++){ ? ? ? ? ? ? ? ?as[i].style.background='none'; ? ? ? ? ? ?} ? ? ? ? ? ?// 如果按下了向下方向鍵 ? ? ? ? ? ?if(e.keyCode==40){ ? ? ? ? ? ? ? ?index++; ? ? ? ? ? ? ? ?if(index>=as.length){ ? ? ? ? ? ? ? ? ? ?index=0; ? ? ? ? ? ? ? ?} ? ? ? ? ? ? ? ?as[index].style.background="#ccc"; ? ? ? ? ? ?} ? ? ? ? ? ?// 如果按下了向上方向鍵 ? ? ? ? ? ?if(e.keyCode==38){ ? ? ? ? ? ? ? ?if(index<=0){ ? ? ? ? ? ? ? ? ? ?index=as.length; ? ? ? ? ? ? ? ?} ? ? ? ? ? ? ? ?index--; ? ? ? ? ? ? ? ?as[index].style.background="#ccc"; ? ? ? ? ? ?} ? ? ? ? ? ?// 如果按下了回車鍵 ? ? ? ? ? ?if(e.keyCode==13 && index!=-1){ ? ? ? ? ? ? ? ?title.innerHTML=as[index].innerHTML; ? ? ? ? ? ? ? ?for(var i=0;i<as.length;i++){ ? ? ? ? ? ? ? ? ? ?as[i].style.background='none'; ? ? ? ? ? ? ? ?} ? ? ? ? ? ? ? ?menu.style.display='none'; ? ? ? ? ? ? ? ?index=-1; ? ? ? ? ? ?} ? ? ? ?} ? ?} ? ?// 滑過滑過、離開、點擊每個選項時 ? ?for(var i=0;i<as.length;i++){ ? ? ? ?as[i].onmouseover=function(){ ? ? ? ? ? ?this.style.background='#ccc'; ? ? ? ?} ? ? ? ?as[i].onmouseout=function(){ ? ? ? ? ? ?this.style.background='none'; ? ? ? ?} ? ? ? ?as[i].onclick=function(){ ? ? ? ? ? ?title.innerHTML=this.innerHTML; ? ? ? ?} ? ?} ? ?// 點擊頁面空白處時 ? ?document.onclick=function(){ ? ? ? ?menu.style.display='none'; ? ?}}
舉報
DOM事件?本課程會通過實例來給小伙伴們講解如何使用這些事件
1 回答上課的源代碼
2 回答為什么源碼不能下載呀
3 回答代碼問題-求幫助
1 回答求HTML和css的代碼
1 回答源碼部署到Tomcat下,布局出現(xiàn)問題。
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網(wǎng)安備11010802030151號
購課補貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號
2017-03-18
視頻的右下角,有“資料下載”下面的“源碼”右面的“下載”就可以下載了?。?/p>
2017-03-06
window.onload=function(){
? ?var box=document.getElementById('divselect'),
? ? ? ? ? ?title=box.getElementsByTagName('cite')[0],
? ? ? ? ? ?menu=box.getElementsByTagName('ul')[0],
? ? ? ? ? ?as=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<as.length;i++){
? ? ? ? ? ? ? ?as[i].style.background='none';
? ? ? ? ? ?}
? ? ? ? ? ?// 如果按下了向下方向鍵
? ? ? ? ? ?if(e.keyCode==40){
? ? ? ? ? ? ? ?index++;
? ? ? ? ? ? ? ?if(index>=as.length){
? ? ? ? ? ? ? ? ? ?index=0;
? ? ? ? ? ? ? ?}
? ? ? ? ? ? ? ?as[index].style.background="#ccc";
? ? ? ? ? ?}
? ? ? ? ? ?// 如果按下了向上方向鍵
? ? ? ? ? ?if(e.keyCode==38){
? ? ? ? ? ? ? ?if(index<=0){
? ? ? ? ? ? ? ? ? ?index=as.length;
? ? ? ? ? ? ? ?}
? ? ? ? ? ? ? ?index--;
? ? ? ? ? ? ? ?as[index].style.background="#ccc";
? ? ? ? ? ?}
? ? ? ? ? ?// 如果按下了回車鍵
? ? ? ? ? ?if(e.keyCode==13 && index!=-1){
? ? ? ? ? ? ? ?title.innerHTML=as[index].innerHTML;
? ? ? ? ? ? ? ?for(var i=0;i<as.length;i++){
? ? ? ? ? ? ? ? ? ?as[i].style.background='none';
? ? ? ? ? ? ? ?}
? ? ? ? ? ? ? ?menu.style.display='none';
? ? ? ? ? ? ? ?index=-1;
? ? ? ? ? ?}
? ? ? ?}
? ?}
? ?// 滑過滑過、離開、點擊每個選項時
? ?for(var i=0;i<as.length;i++){
? ? ? ?as[i].onmouseover=function(){
? ? ? ? ? ?this.style.background='#ccc';
? ? ? ?}
? ? ? ?as[i].onmouseout=function(){
? ? ? ? ? ?this.style.background='none';
? ? ? ?}
? ? ? ?as[i].onclick=function(){
? ? ? ? ? ?title.innerHTML=this.innerHTML;
? ? ? ?}
? ?}
? ?// 點擊頁面空白處時
? ?document.onclick=function(){
? ? ? ?menu.style.display='none';
? ?}
}