第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

為什么我的懸停功能可以工作,但我的 onmouseleave 功能卻不能?(在控制臺(tái)調(diào)用該函數(shù)有效)

為什么我的懸停功能可以工作,但我的 onmouseleave 功能卻不能?(在控制臺(tái)調(diào)用該函數(shù)有效)

浮云間 2024-01-22 15:28:53
這是我的代碼筆:https://codepen.io/squishyboots19996/pen/BaoQjPL我正在嘗試創(chuàng)建一個(gè)導(dǎo)航菜單,當(dāng)您將鼠標(biāo)懸停在箭頭上時(shí),該菜單會(huì)滑入,然后當(dāng)鼠標(biāo)離開(kāi)菜單時(shí)會(huì)滑開(kāi)。我有 UIController.showMenu 和 UIController.closeMenu。如果我在控制臺(tái)中調(diào)用其中任何一個(gè),它們就會(huì)按預(yù)期工作。但是 closeMenu 的事件偵聽(tīng)器不起作用。它只是沒(méi)有檢測(cè)到鼠標(biāo)離開(kāi)菜單并且沒(méi)有關(guān)閉。如果我向函數(shù)添加 console.log("Hello") ,它將在頁(yè)面首次加載時(shí)觸發(fā)。但當(dāng)我需要它時(shí)就不起作用了。應(yīng)用程序.js:var Controller = (function() {    UIController.updateNav;    setInterval(UIController.moveArrowDown, 3000);    //UIController.addBodyMargin(); document.querySelector('#menuArrow').addEventListener("mouseover", UIController.openMenu);      document.querySelector('#sideMenu').addEventListener("onmouseleave", UIController.closeMenu);});//-----------------------------------------------------------var UIController = (function() {    return {        openMenu: (function(){          document.getElementById('sideMenu').style.marginLeft = '0';          document.getElementById('menuArrow').style.marginLeft = '250px';          document.body.style.marginLeft = '25px'        }),        closeMenu: (function(){          document.getElementById('sideMenu').style.marginLeft = '-250px';          document.getElementById('menuArrow').style.marginLeft = '0';          document.body.style.marginLeft = '0';        })        }})();document.addEventListener('DOMContentLoaded', (event) => {  Controller();})導(dǎo)航欄.css:.sidemenu {  height: 100vh;  width: 250px;  position: fixed;  top: 0;  left: 0;  background-color: red;  z-index: 5001;  display: flex;  flex-direction: column;  justify-content: center;  align-items: center;  margin-left: -250px;  transition: .5s;  cursor: pointer;}.sidemenu ul {  list-style: none;  padding: 0;}.sidemenu a {  text-decoration: none;  font-size: 2rem;}.expand-arrow {  z-index: 4999;  position: fixed;  transition: .5s;  bottom: 50%;}
查看完整描述

2 回答

?
叮當(dāng)貓咪

TA貢獻(xiàn)1776條經(jīng)驗(yàn) 獲得超12個(gè)贊

使用該addEventListener()方法時(shí),"mouseleave"不是"onmouseleave"



查看完整回答
反對(duì) 回復(fù) 2024-01-22
?
慕森王

TA貢獻(xiàn)1777條經(jīng)驗(yàn) 獲得超3個(gè)贊

添加事件時(shí)不應(yīng)使用“on”,只需使用函數(shù)名稱

document.querySelector('#sideMenu').addEventListener("mouseleave", UIController.closeMenu);

代替

document.querySelector('#sideMenu').addEventListener("onmouseleave", UIController.closeMenu);



查看完整回答
反對(duì) 回復(fù) 2024-01-22
  • 2 回答
  • 0 關(guān)注
  • 212 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)