xuxianxiu
2016-07-29 22:44
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; } menu.style.display = "block"; // 执行脚本 } for(var i=0;i<as.length;i++){ as[i].onmouseover = function(){ this.style.background = "#456"; } as[i].onmouseout = function(){ this.style.background = "#fff"; } as[i].onclick = function(event){ event = event || window.event; if(event.stopPropagation){ event.stopPropagation; } else{ event.cancelBubble; } menu.style.display = "none"; title.innerHTML = this.innerHTML; } } // 滑过滑过、离开、点击每个选项时 // 执行脚本 document.onclick = function(){ menu.style.display = 'none'; }; // 点击页面空白处时 // 执行脚本 }
event.cancelBubble=true;
DOM事件探秘
99545 学习 · 1197 问题
相似问题