亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

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

如果它具有作為子項的跨度,則將類添加到父 div

如果它具有作為子項的跨度,則將類添加到父 div

DIEA 2021-10-21 10:49:16
我有許多過濾器可以在我的商店中顯示產品。我正在使用 bootstrap-select 來設置過濾器(下拉菜單)的樣式。當我更改過濾器值時,如果該組合沒有可用的結果,其他過濾器會自動隱藏選項。問題是,現在有一個過濾器顯示沒有任何可用選項可供選擇。在這種情況下,我想完全隱藏過濾器。如果有可用選項,代碼如下所示:<div class="form-group ">  <label>Serie</label>  <div class="btn-group bootstrap-select show-tick js-wpv-filter-trigger form-control open"><button type="button" class="btn dropdown-toggle bs-placeholder btn-dropdown btn-default" data-toggle="dropdown" role="button" data-id="wpv_control_select_wpcf-serie" title="Bitte w?hlen..." aria-expanded="true">  <span class="filter-option pull-left">Bitte w?hlen...</span>  <span class="bs-caret">    <span class="caret"></span>  </span>  </button>    <div class="dropdown-menu open" role="combobox">      <ul class="dropdown-menu inner" role="listbox" aria-expanded="true">        <li data-original-index="0"><a tabindex="0" class="" data-tokens="null" role="option" aria-disabled="false" aria-selected="false"><span class="text">D-9</span><span class="fontawesome fa fa-check check-mark"></span></a></li>      </ul>    </div>    <label class="custom-select">      <select id="wpv_control_select_wpcf-serie" name="wpv-wpcf-serie[]" class="selectpicker js-wpv-filter-trigger form-control" multiple="multiple" tabindex="-98">        <option value="D-9">D-9</option>      </select>      <span></span>    </label>  </div></div>我的目標是一類添加.hide-filter到.form-group如果孩子.dropdown-menu沒有li
查看完整描述

2 回答

?
UYOU

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

這是另一種方法:


$( document ).ready(function() {

    if($( ".dropdown-menu.inner:has(li)" ).length == 0){

      $( ".form-group" ).addClass( "hide-filter" );

    }

});  


查看完整回答
反對 回復 2021-10-21
  • 2 回答
  • 0 關注
  • 155 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

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

公眾號

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