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

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

當(dāng)#links(同頁(yè)鏈接)被點(diǎn)擊時(shí),如何隱藏菜單?

當(dāng)#links(同頁(yè)鏈接)被點(diǎn)擊時(shí),如何隱藏菜單?

有人可以告訴我,如果任何(同一頁(yè)面鏈接)被點(diǎn)擊或有人點(diǎn)擊菜單區(qū)域之外,我如何使我的漢堡菜單再次消失?我認(rèn)為我需要在我的JS腳本代碼中添加一些東西,但我似乎找不到正確的東西來(lái)改變或添加。在JavaScript方面,我完全是新手。#linksconst menuBtn = document.querySelector('.menu-btn');let menuOpen = false;menuBtn.addEventListener('click', () => {  if (!menuOpen) {    menuBtn.classList.add('open');    document.getElementById("mymobilemenu").style.display = "block";    menuOpen = true;  } else {    menuBtn.classList.remove('open');    document.getElementById("mymobilemenu").style.display = "none";    menuOpen = false;  }});
查看完整描述

2 回答

?
湖上湖

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

您好,您可以通過(guò)將 foreach 添加到 來(lái)執(zhí)行此操作,因此每次有人單擊該內(nèi)容時(shí),腳本都會(huì)將打開(kāi)的類(lèi)刪除到菜單。<li>


const menuBtn = document.querySelector('.menu-btn');

let menuOpen = false;

menuBtn.addEventListener('click', () => {

  if (!menuOpen) {

    menuBtn.classList.add('open');

    document.getElementById("mymobilemenu").style.display = "block";

    menuOpen = true;

  } else {

    menuBtn.classList.remove('open');

    document.getElementById("mymobilemenu").style.display = "none";

    menuOpen = false;

  }

});

let  menuli = document.querySelectorAll('#mymobilemenu li');

menuli.forEach((item, index) => {

 item.addEventListener('click', () => {

 menuBtn.classList.remove('open');

    document.getElementById("mymobilemenu").style.display = "none";

    menuOpen = false;

 

});


});

.menu-btn {

  position: relative;

  float: right;

  display: flex;

  justify-content: center;

  align-items: center;

  width: 80px;

  height: 80px;

  cursor: pointer;

  transition: all .5s ease-in-out;

  border: 3px solid blueviolet;

  background: pink;

}


.menu-btn-burger {

  width: 50px;

  height: 6px;

  background: yellow;

  border-radius: 5px;

  transition: all .5s ease-in-out;

}


.menu-btn-burger::before,

.menu-btn-burger::after {

  content: '';

  position: absolute;

  width: 50px;

  height: 6px;

  background: grey;

  border-radius: 5px;

  transition: all .5s ease-in-out;

}


.menu-btn-burger::before {

  transform: translateY(-16px);

}


.menu-btn-burger::after {

  transform: translateY(16px);

}



/* animation of burger */


.menu-btn.open .menu-btn-burger {

  transform: translateX(-50px);

  background: transparent;

  box-shadow: none;

}


.menu-btn.open .menu-btn-burger::before {

  transform: rotate(45deg) translate(35px, -35px);

}


.menu-btn.open .menu-btn-burger::after {

  transform: rotate(-45deg) translate(35px, 35px);

}


#mymobilemenu {

  display: none;

}

<div class="menu-btn">

  <div class="menu-btn-burger">

  </div>

</div>


<div id="mymobilemenu">

  <li><a href="#section1">section1</a></li>

  <li><a href="#section2">section2</a></li>

  <li><a href="#section3">section3</a></li>

  <li><a href="#section4">section4</a></li>

</div>


<a id="section1">SECTION 1</a>

<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has

  survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing

  software like Aldus PageMaker including versions of Lorem Ipsum. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a

  galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets

  containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's

  standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.

  It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>


<a id="section2">SECTION 2</a>

<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has

  survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing

  software like Aldus PageMaker including versions of Lorem Ipsum. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a

  galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets

  containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's

  standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.

  It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>


<a id="section3">SECTION 3</a>

<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has

  survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing

  software like Aldus PageMaker including versions of Lorem Ipsum. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a

  galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets

  containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's

  standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.

  It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>


<a id="section4">SECTION 4</a>

<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has

  survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing

  software like Aldus PageMaker including versions of Lorem Ipsum. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a

  galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets

  containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's

  standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.

  It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>


查看完整回答
反對(duì) 回復(fù) 2022-09-02
?
明月笑刀無(wú)情

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

嘗試將其添加到您的js腳本中:


const a = document.querySelectorAll('.a');

a.forEach(element => {

  element.addEventListener('click', () => {

    menuBtn.classList.remove('open');

    document.getElementById("mymobilemenu").style.display = "none";

    console.log("removed");

  })


});


查看完整回答
反對(duì) 回復(fù) 2022-09-02
  • 2 回答
  • 0 關(guān)注
  • 102 瀏覽
慕課專(zhuān)欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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