ecshop商品子分类点击下拉,子分类空时,直接跳转功能

模板文件循环读取商品分类,并给大分类加上url属性。然后在js中判断是否有下级分类。有分类则点击下拉效果,没有子分类则跳转到url属性的链接去。

 

themes/**/library/category_tree.lbi:

<div class="navBar">

  <div id="cate">
  <!--{foreach from=$categories_pro item=cat name=categories_pro}-->
        <h1  class="h1">
        <dt > <a href="javascript:;" url="{$cat.url}">{$cat.name|escape:html} <span class="searchLeft"></span></a> </dt>
        </h1>
        <ul {if $cat.id  eq $parent_id_show}style="display:block"{/if}>
         <!--{foreach from=$cat.cat_id item=child}-->
        <li><a href="{$child.url}" {if $child.id eq $category}class="current"{/if}>{$child.name|escape:html}</a></li>
        <!--{/foreach}-->
        </ul>
        <div style="clear:both"></div>
    

    <!--{/foreach}--> 
</div>

</div>

 

/js/common.js:

//列表页商品分类左侧导航点击切换
    $("#cate h1").click(function(){
        if($(this).next("ul").find("li").length == 0) {
            location.href = $(this).find("a").attr("url");//location.href实现客户端页面的跳转  
        }
        else { 
            if($(this).next("ul").is(":visible"))
            {
                $(this).next("ul").hide();    
            }
            else
            {
                $("#cate ul").hide();    
                $(this).next("ul").show();    
            }
        }
    })

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值