我尝试隐藏div class =“ admi-mm-{{$ cat_no}}”
在加载并在悬停事件中显示它时,当您将鼠标悬停在一个带有子菜单的div上时,我会为此主类别创建动态div
@foreach($categories as $main_cat)
<?php $cat_no += 1 ?>
<li class="admi-menu-{{$cat_no}}">
<a href="#" class="mm-arr">{{$main_cat->title}}</a>
<!-- MEGA MENU 1 -->
<div class="mm-pos">
<style>
.admi-mm-{{$cat_no}} {
display:none;
}
</style>
<div class="admi-mm-{{$cat_no}} m-menu">
<div class="m-menu-inn">
@php ($sub_cat = DB::table('category')->where('parent_id','=',$main_cat->id)->orderby('id','asc')->get())
@foreach($sub_cat as $sub_level)
<div class="mm2-com mm1-com mm1-s1">
<div class="ed-course-in">
<a class="course-overlay" href="{{ url('/allpackage') }}/{{$sub_level->id}}">
<img src="{{ Request::root() }}/website/images/sight/{{$sub_level->image}}" alt="">
<span>{{$sub_level->title}}</span>
</a>
</div>
<a href="{{ url('/allpackage') }}/{{$sub_level->id}}" class="mm-r-m-btn">عرض التفاصيل</a>
</div>
@endforeach
</div>
</div>
</div>
</li>
@endforeachhere
答案 0 :(得分:0)
这是我的jquery代码
var x = 1;
for (x = 1; x < 6; x++) {
//MEGA MENU
$(".admi-menu"+x+"").hover(function() {
$(".admi-mm-"+x+"").fadeIn();
});
$(".admi-menu"+x+"").mouseleave(function() {
$(".admi-mm-"+x+"").fadeOut();
});
}