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

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

如何在js中通過其值隱藏按鈕?

如何在js中通過其值隱藏按鈕?

白衣非少年 2022-01-07 21:06:51
如何按其值隱藏按鈕?例子 :<button class="mat-raised-button mat-primary" color="primary" mat-raised-button="">    <span class="mat-button-wrapper">RESET</span>    <div class="mat-button-ripple mat-ripple" matripple=""></div>    <div class="mat-button-focus-overlay"></div></button>其實我想隱藏這個有RESET的按鈕。但我無法在其類的幫助下隱藏它,因為同一個類正在其他按鈕中使用。如果嘗試使用類名隱藏所有具有相同類的按鈕將被隱藏。有什么幫助嗎?
查看完整描述

3 回答

?
慕標5832272

TA貢獻1966條經驗 獲得超4個贊

你的問題不清楚。你是這個意思嗎?


var elements = document.getElementsByClassName("mat-button-wrapper");

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

  elements[i].style.display = "none";

  console.log("Hidden: " + elements[i]);

}


查看完整回答
反對 回復 2022-01-07
?
慕斯王

TA貢獻1864條經驗 獲得超2個贊

如果您想隱藏此按鈕:


<button class="mat-raised-button mat-primary" color="primary" mat-raised-button="">

    <span class="mat-button-wrapper">RESET</span>

    <div class="mat-button-ripple mat-ripple" matripple=""></div>

    <div class="mat-button-focus-overlay"></div>

</button>

因為它包含這個詞 RESET


您可以使用以下內容:


// Get all relevant buttons

let myButtons = [...document.getElementsByClassName('mat-raised-button')];


// Cycle through buttons

myButtons.forEach((button) => {


  let matButtonWrapper = button.getElementsByClassName('mat-button-wrapper')[0];


  // Execute actions according to the mat-button-wrapper text

  switch(matButtonWrapper.textContent) {


    case ('RESET') : button.style.opacity = '0'; break;

    // case ('Another word here') : actions here; break;

    // case ('Another word here') : actions here; break;

    // case ('Another word here') : actions here; break;

    // case ('Another word here') : actions here; break;

  }


});


查看完整回答
反對 回復 2022-01-07
?
慕村225694

TA貢獻1880條經驗 獲得超4個贊

首先你的問題不清楚,我不能很好地理解你到底想做什么以及你將如何做。如果您使用 JS ,請使用關鍵字 'this' , 'this' 將作用于按鈕觸發(fā)事件的當前范圍。


例子:


document.querySelector('button class').on('click', function() { 


   this.el.style.display = 'none'


});

當然,在事件函數中,您可以獲取單擊按鈕的值并檢查它的值。


或者您可以將 clicked el 傳遞給函數:


document.querySelector('button class').on('click', function(el) { 


           var value = el.value;


           if(value === 'something') {

               el.style.display = 'none'

           }

        });


查看完整回答
反對 回復 2022-01-07
  • 3 回答
  • 0 關注
  • 368 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號