Edit This Code:
Compile
<!DOCTYPE html> <html> <head> <style type="text/css"> .nav_menu { width:100%; background-color:#EFEFEF; z-index:2000; border:1px solid #ccc; } .selected { background-color:#ccc; color:#333; } .nav_menu a:link { color:#007dc1; } .nav_menu a:visited { color:#007dc1; } .nav_menu a:hover { color:#007dc1; } .nav_menu ul { text-align: left; display: inline; margin: 0; padding: 15px 4px 17px 0; list-style: none; } .nav_menu ul li { font-size:16px; display: inline-block; margin-right: -4px; position: relative; padding: 8px 22px; font-weight:600; transition: all 50ms linear; transition-delay: 0s; } .nav_menu ul li ul { padding: 0; position: absolute; top: 37px; left: 0; width: 230px; -webkit-box-shadow: none; -moz-box-shadow: none; box-shadow: none; display: none; opacity: 0; visibility: hidden; display: block; opacity: 0; -webkit-transition: opacity .2s; z-index:50000; } .nav_menu ul li ul li { background-color:#535353; border-top:1px solid #fff; display: block; font-size:12px; color:#fff; } .nav_menu ul li ul li:hover { background: #B2B2B2; } .nav_menu ul li:hover ul { display: block; opacity: 1; visibility: visible; background-color:red; } .nav_menu_sub ul { margin-top:-7px; display: none !important; } .nav_menu_sub:hover ul { display: block !important; opacity: 1; visibility: visible; } </style> <script type="text/javascript"> function hide(elem){ console.log('qua'); document.getElementById("asd").style.display = 'block'; } function lol(elem){ var openMenu = document.getElementById("asd"); console.log('qui'); //document.getElementById("asd").style.display = 'none'; //setTimeout(function(){ hide(elem); }, 500); } </script> </head> <body> <div id="focus" onclick="hide()">test</div> <div class='nav_menu'> <ul id="menu"> <li>All Items <ul> <li>Item 1</li> <li>Item 2</li> <li id="asd" class='nav_menu_sub'>Item 3 with Sub Menu <ul> <li>SubItem 3.1</li> <li><a href"#" onclick="lol(this)">SubItem 3.2</li> </ul> </li> </ul> </li> </ul> </div> </body> </html>
Result:
New
Save