JS code Implementation drop-down menu

Source: Internet
Author: User

Effect

JS Code:

<script type= "Text/javascript" >
function Showsub (LI) {//functions definition
var submenu = Li.getelementsbytagname ("ul") [0];//Get
SubMenu.style.display = "block";
}

function Hidesub (LI) {
var submenu = Li.getelementsbytagname ("ul") [0];
SubMenu.style.display = "None";
}

</script>

CSS style:

*{margin:0px; padding:0px;}
body{Font-family:verdana, Geneva, Sans-serif; font-size:14px;}
#nav {width:600px; height:40px; Background-color: #eee; margin:0 auto;}
ul{List-style:none;}
UL li{Float:left; line-height:40px; text-align:center; width:100px;} IE7 display width compatibility setting width without padding adaptive
a{text-decoration:none; color: #000; display:block;}
a:hover{color: #F00; Background-color: #666;}
UL Li ul li{float:none;background-color: #eee; margin:2px 0px;}
UL Li ul{display:none;}

HTML code

<div id= "NAV" >

<ul>
<li><a href= "#" > Home </a></li>
<li onmouseover= "Showsub (This)" onmouseout= "hidesub (This)" ><a href= "#" > Course Hall </a>
<ul>
<li><a href= "#" >JavaScript</a></li>
<li><a href= "#" >Html/CSS</a></li>
</ul>
</li>
<li onmouseover= "Showsub (This)" onmouseout= "hidesub (This)" ><a href= "#" > Learning Center </a>
<ul>
<li><a href= "#" > Video Learning </a></li>
<li><a href= "#" > Example Exercises </a></li>
<li><a href= "#" > Ask and Answer </a></li>
</ul>

</li>
<li><a href= "#" > Classic case </a></li>
<li><a href= "#" > About Us </a></li>
</ul>

</div>

JS code Implementation drop-down menu

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.