相關關鍵詞
關于我們
最新文章
thinkPHP實現(xiàn)的聯(lián)動菜單功能詳解

本文實例講述了thinkPHP實現(xiàn)的聯(lián)動菜單功能。分享給大家供大家參考,具體如下:
聯(lián)動菜單,首先給你看看前端是怎么寫的:
<div id="newCat"> <div class="all_type" id="allGoogsCat">所有商品分類</div> <div class="spfl-warp <?php if(CONTROLLER_NAME != 'Index' || ACTION_NAME != 'index'){echo 'hide';} ?> "> <div class="index-spfl-left" id="divCatList"> <ul> <foreach name="category_menu" key="one" item="v"> <li class="li{$one+1}"> <span><em></em> <a href="{:U('Category/index',array('id'=>$v['category_id'],'level'=>1))}" rel="external nofollow" >{$v.category_name}</a> </span> <div class="div none"> <foreach name="v['childs']" key="two" item="v2"> <dl> <dt> <a href="{:U('Category/index',array('id'=>$v2['category_id'],'level'=>2))}" rel="external nofollow" >{$v2.category_name}</a> </dt> <dd class="fl"> <foreach name="v2['childs']" item="v3"> <a href="{:U('Category/index',array('id'=>$v3['category_id'],'level'=>3))}" rel="external nofollow" > {$v3.category_name} </a> </foreach> </dd> <div class="cl"></div> </dl> </foreach> </div> </li> </foreach> </ul> </div> </div> </div> <script type="text/javascript"> <?php if(CONTROLLER_NAME != 'Index' || ACTION_NAME != 'index'){ ?> //商品分類鼠標滑過 function spflHover() { $(".index-spfl-left ul li").live("mouseover", function () { $(this).addClass("active").siblings().removeClass("active"); $(".index-spfl-left").find(".div").hide(); $(this).find(".div").show(); }).live("mouseout", function () { $(this).removeClass("active"); $(".index-spfl-left").find(".div").hide(); $(this).find(".div").hide(); }); //鼠標滑過分類顯示 $("#newCat").mouseover(function () { $(".spfl-warp").show(); }).mouseout(function () { if ($("#ismain").val() == "1") { $(".spfl-warp").show(); } else { $(".spfl-warp").hide(); } }) } spflHover(); <?php } ?> </script>