
如果它下面有任何子選單,我想顯示這個下拉圖示。亞洲在子選單上有國家(在其下的國家(中國/韓國),但美國沒有。
下拉選單的形成

html
<div class="dropdown">
<button type="button" class="btn btn-custom btn btn-outline-light text-light"
style="font-family: Times New Roman; font-weight: bold; font-style: italic;">Country</button>
<div class="dropdown-content">
@foreach($subcontinents as $subcontinent)
<a><div class="dropdown2">
@if(is_null($subcontinent->countries))
<button class="dropbtn2">{{$subcontinent->subcontinent_name}}</button>
@else
<button class="dropbtn2">{{$subcontinent->subcontinent_name}}<i class="fa fa-caret-right pl-3" aria-hidden="true"></i></button>
@endif
<div class="dropdown-content2">
@foreach($subcontinent->countries as $division)
<a href="" >{{$division->country_name}}</a>
@endforeach
</div>
</div>
</a>
@endforeach
</div>
</div>
資料庫
次大陸有許多國家。
如果一個次大陸有國家/非空的國家,那么將會有右下角的圖示。
uj5u.com熱心網友回復:
<div class="dropdown">
<button type="button" class="btn btn-custom btn btn-outline-light text-light"
style="font-family: Times New Roman; font-weight: bold; font-style: italic;">Country</button>
<div class="dropdown-content">
@foreach($subcontinents as $subcontinent)
<a><div class="dropdown2">
<button class="dropbtn2">{{$subcontinent->subcontinent_name}}
// You can check here if your values aren't empty or greater than 0. based on that you can show. you can also use !empty() here.
@if(count($subcontinent->countries) > 0)<i class="fa fa-caret-right pl-3" aria-hidden="true"></i>@endif
</button>
<div class="dropdown-content2">
@foreach($subcontinent->countries as $division)
<a href="" >{{$division->country_name}}</a>
@endforeach
</div>
</div>
</a>
@endforeach
</div>
</div>
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/351642.html
