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

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如果單擊類,則執(zhí)行此操作,否則執(zhí)行此操作?

如果單擊類,則執(zhí)行此操作,否則執(zhí)行此操作?

斯蒂芬大帝 2023-09-28 09:58:25
我有一個打開下拉菜單的按鈕。單擊某個選項或關(guān)閉菜單后,下拉選項就會消失。我需要嘗試建立太不同的功能,一個是如果單擊菜單項,另一個是如果未單擊菜單項(即屏幕的不同部分)。我嘗試通過 - 如果類對象包含“.menubtns”執(zhí)行此操作..否則....// Close the dropdown menu if the user clicks outside of itwindow.onclick = function(event) {  if (!event.target.matches('.dropbtn')) {    var dropdowns = document.getElementsByClassName("dropdown-content");    var i;    for (i = 0; i < dropdowns.length; i++) {      var openDropdown = dropdowns[i];      /// here is where the behaviour needs to be added //////////      if (openDropdown.classList.contains('show') &&        ($(this.target).hasClass('menubtns'))) {        openDropdown.classList.remove('show');        console.log('you have clicked an option');      } else {        console.log('not clicked on an option')        openDropdown.classList.remove('show');        mainpageaccessibility();      }    }  }這樣我就可以在彈出模式中設(shè)置選項卡順序。目前,它打開模式,但也運行“mainpageaccessibility();” 然后刪除所有 taborders。任何幫助將不勝感激!
查看完整描述

2 回答

?
森欄

TA貢獻1810條經(jīng)驗 獲得超5個贊

我無法測試這個,但看來你在應(yīng)該使用“事件”的地方使用了“這個”


“this”指的是窗口對象。


// Close the dropdown menu if the user clicks outside of it

window.onclick = function(event) {

    if (!event.target.matches('.dropbtn')) {

        var dropdowns = document.getElementsByClassName("dropdown-content");

        var i;

        for (i = 0; i < dropdowns.length; i++) {

            var openDropdown = dropdowns[i];


            /// here is where the behaviour needs to be added //////////

            if (openDropdown.classList.contains('show') &&

                ($(event.target).hasClass('menubtns'))) {


                openDropdown.classList.remove('show');

                console.log('you have clicked an option');


            } else {

                console.log('not clicked on an option')

                openDropdown.classList.remove('show');

                mainpageaccessibility();


            }

        }

    }

}


查看完整回答
反對 回復(fù) 2023-09-28
?
慕標5832272

TA貢獻1966條經(jīng)驗 獲得超4個贊

我無法測試這個,但看來你在應(yīng)該使用“事件”的地方使用了“這個”


“this”指的是窗口對象。


// Close the dropdown menu if the user clicks outside of it

window.onclick = function(event) {

    if (!event.target.matches('.dropbtn')) {

        var dropdowns = document.getElementsByClassName("dropdown-content");

        var i;

        for (i = 0; i < dropdowns.length; i++) {

            var openDropdown = dropdowns[i];


            /// here is where the behaviour needs to be added //////////

            if (openDropdown.classList.contains('show') &&

                ($(event.target).hasClass('menubtns'))) {


                openDropdown.classList.remove('show');

                console.log('you have clicked an option');


            } else {

                console.log('not clicked on an option')

                openDropdown.classList.remove('show');

                mainpageaccessibility();


            }

        }

    }

}


查看完整回答
反對 回復(fù) 2023-09-28
  • 2 回答
  • 0 關(guān)注
  • 137 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

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