Skip to content

Instantly share code, notes, and snippets.

@cxytomo
Created October 14, 2012 15:45
Show Gist options
  • Save cxytomo/3888970 to your computer and use it in GitHub Desktop.
Save cxytomo/3888970 to your computer and use it in GitHub Desktop.
dropdown(including mouseout)
document.getElementsByClassName('open')[0].addEventListener('mouseover',function(e) {
var el,show;
e = e || window.event;
e.cancelBubble = true;
if (e.stopPropagation) e.stopPropagation();
el = document.getElementsByClassName('open')[0];
show = el.getElementsByClassName('dropdown-menu')[0];
show.style.display = "block";
},false);
var hide = function(e) {
var el,hide;
e = e || window.event;
e.cancelBubble = true;
if (e.stopPropagation) e.stopPropagation();
el = document.getElementsByClassName('open')[0];
hide = el.getElementsByClassName('dropdown-menu')[0];
hide.style.display = "none";
}
document.getElementsByClassName('open')[0].addEventListener('mouseout',hide,false);
document.getElementsByClassName('open')[0].getElementsByClassName('dropdown-menu')[0].addEventListener('mouseout',hide,false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment