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

為了賬號(hào)安全,請及時(shí)綁定郵箱和手機(jī)立即綁定

老師我在 item.addEventListener中的 li.children[1].classList.remove("active");一直報(bào)錯(cuò)說 Cannot read property 'classList' of undefined

class?Menu?{

??constructor(id)?{

????this.box?=?document.querySelector(id)


????this.ul?=?this.box.querySelector("ul");

????this.lis?=?this.box.querySelectorAll("li");//因?yàn)橛卸鄠€(gè)li結(jié)點(diǎn),所以加All

????this.subMenu?=?this.box.querySelectorAll(".sub-menu");

????this.time1?=?null;

????this.time2?=?null;


????this.init();//調(diào)用init

??}

??init()?{

????console.log("menu");

???

????this.lis.forEach((item)?=>?{

??????

??????item.addEventListener("mouse",?(e)?=>?{

????????let?li?=?e.target;

????????console.log("mouse");


??????????this.time1=setTimeout(()=>

??????????{

????????????this.subMenu.forEach((item)=>

????????????{

??????????????item.classList.remove("active");

????????????})//在這里用循環(huán)


?????????????if(this.time1?!=null)

?????????????{

???????????????clearInterval(this.time1);

?????????????}


????????????li.children[1].classList.add("active");//children[1]就是li下的第二個(gè)子類

??????????},200)

??????})

????});

????//item.addEventListenneer代表鼠標(biāo)觸發(fā)事件,e有點(diǎn)像函數(shù)一樣包含其中的事件


????this.lis.forEach((item)?=>?{

??????item.addEventListener("mouseleave",?(e)?=>?{

????????let?li?=?e.target;

????????console.log("mouseleave");


????????this.time2=setTimeout(()?=>?{

??????????this.subMenu.forEach((item)=>

????????????{

??????????????item.classList.remove("active");

????????????})//在這里用循環(huán)

??????????li.children[1].classList.remove("active");

????????},200)

??????})

????});

??}



}



正在回答

1 回答

你發(fā)的代碼錯(cuò)誤百出,核對一下代碼吧。

報(bào)錯(cuò)是發(fā)生在倒數(shù)第二個(gè)remove那里的,第一個(gè)循環(huán)的事件是mouseenter不是mouse,而且你第二個(gè)循環(huán)那里怎么有兩個(gè)循環(huán)?而且怎么是item.classList?

0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

老師我在 item.addEventListener中的 li.children[1].classList.remove("active");一直報(bào)錯(cuò)說 Cannot read property 'classList' of undefined

我要回答 關(guān)注問題
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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