简体   繁体   中英

Drop down list not working

Why does the drop down list fades away when the mouse moves out of the very first element of the list.The list should fad out only when the mouse moves out of the entire list?Please help.

<html>
<head>

<style>
ul{
list-style-type:none;
}

li{
float:left;
}
#hidden2{
display:none;
}
</style>
</head>
<body>
<ul>
    <li >
        <a href="#" onclick="return false;" onmousedown="hidden2.style.display='block'">Names</a> 
            <ul id="hidden2" onmouseout="style.display='none'"> 
                <li><a  href="#">Name1</a>
                    <a  href="#">Name2</a>
                    <a  href="#">Name3</a>
                    <a  href="#">Name4</a>
                </li>
            </ul>       
    </li>
</ul>
<body>
</html>

Try onmouseleave instead of onmouseout

<ul>
    <li >
        <a href="#" onclick="return false;" onmousedown="hidden2.style.display='block'">Names</a> 
            <ul id="hidden2" onmouseleave="style.display='none'"> 
                <li><a  href="#">Name1</a>
                    <a  href="#">Name2</a>
                    <a  href="#">Name3</a>
                    <a  href="#">Name4</a>
                </li>
            </ul>       
    </li>
</ul>

JSFIDDLE

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM