你需要让“父母”类知道任何 LI
<div id="accordion">
<h3 class="parent">{{$category->title}}</h3>
<div>
<ul>
<li><a href="{{url($langSlug .'/products/category/' .$category->slug)}}" class="triangle {{$category->slug}}">All Products {{$category->title}} <span>({{$category->products->count()}})</span></a></li>
@foreach($category->children as $category_child)
<li>
<a href="{{url($langSlug .'/products/category/' .$category_child->slug)}}" class="triangle {{$category_child->slug}}">{{$category_child->title}} <span>({{$category_child->products->count()}})</span></a>
</li>
@endforeach
</ul>
</div>
</div>
1 个回答