为什么mouseover和mouseout在javascript中不能正常工作?
我有一个钮扣为什么mouseover和mouseout在javascript中不能正常工作?,javascript,html,css,Javascript,Html,Css,我有一个钮扣 <button onmouseover="Lobby()" class="menuBtn"> Lobby </button> 然后我有了一种风格 #lobby { display: none; height: 100%; width: 16%; } 我有一个div <div onmouseout="HideLobby()" class="submenupanel" id="lobby"> <button on
<button onmouseover="Lobby()" class="menuBtn"> Lobby </button>
然后我有了一种风格
#lobby
{
display: none;
height: 100%;
width: 16%;
}
我有一个div
<div onmouseout="HideLobby()" class="submenupanel" id="lobby">
<button onclick="" class="l">Lobby</button>
<button onclick="GoToHelpDesk()" class="l">Information Center</button>
<button onclick="ProductDisplay()" class="l">Product Display</button>
</div>
所以,当我悬停到大厅按钮时,它会显示应该显示的div。当我将鼠标从div中取出时,它应该隐藏起来。但当我将鼠标悬停在
信息中心
或产品显示
上时,div正在隐藏。为什么?使用onmouseleave
代替onmouseout
鼠标指针离开任何子对象时触发mouseout事件
元素以及选定的元素
mouseleave事件仅在鼠标指针离开时触发
选定的元素
功能大厅(){
document.getElementById(“大厅”).style.display=“块”;
}
函数HideLobby(事件){
document.getElementById(“大厅”).style.display=“无”;
}
大厅{
显示:无;
身高:100%;
宽度:16%;
}
大厅
大堂
信息中心
产品展示
使用onmouseleave
代替onmouseout
鼠标指针离开任何子对象时触发mouseout事件
元素以及选定的元素
mouseleave事件仅在鼠标指针离开时触发
选定的元素
功能大厅(){
document.getElementById(“大厅”).style.display=“块”;
}
函数HideLobby(事件){
document.getElementById(“大厅”).style.display=“无”;
}
大厅{
显示:无;
身高:100%;
宽度:16%;
}
大厅
大堂
信息中心
产品展示
因为您在整个div上编写了HideLobby函数,所以也有mouseenter
和mouseleave
事件。因为您在整个div上编写了HideLobby函数,所以也有mouseenter
和mouseleave
事件。告诉我更多帮助告诉我更多帮助
<div onmouseout="HideLobby()" class="submenupanel" id="lobby">
<button onclick="" class="l">Lobby</button>
<button onclick="GoToHelpDesk()" class="l">Information Center</button>
<button onclick="ProductDisplay()" class="l">Product Display</button>
</div>
function HideLobby()
{
document.getElementById("lobby").style.display = "none";
}