jquery京东新版左侧下拉分类导航菜单代码

下载地址

$(".all-sort-list >.item").hover(function () { var eq = $(".all-sort-list >.item").index(this), h = $(".all-sort-list").offset().top, s = $(window).scrollTop(), i = $(this).offset().top, item = $(this).children(".item-list").height(), sort = $(".all-sort-list").height(); if (item < sort) { if (eq == 0) { $(this).children(".item-list").css("top", (i - h)); } else { $(this).children(".item-list").css("top", (i - h) + 1); } } else { if (s >h) { if (i - s >0) { Bug, $(this).children(".item-list").css("top", (s - h) + 2); } else { $(this).children(".item-list").css("top", (s - h) - (-(i - s)) + 2); } } else { $(this).children(".item-list").css("top", 3); } } $(this).addClass("hover"); $(this).children(".item-list").css("display", "block"); }, function () { $(this).removeClass("hover"); $(this).children(".item-list").css("display", "none"); }); $(".item >.item-list >.close").click(function () { $(this).parent().parent().removeClass("hover"); $(this).parent().hide(); });

728f98473805c8e295f6559ec9e90c2857639.png

dd:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是一个简单的jQuery代码,可以实现类似腾讯云的滑动下导航菜单效果: HTML代码: ```html <div class="dropdown"> <button class="dropbtn">菜单</button> <div class="dropdown-content"> <a href="#">链接1</a> <a href="#">链接2</a> <a href="#">链接3</a> </div> </div> ``` CSS样式: ```css .dropdown { position: relative; display: inline-block; } .dropdown-content { display: none; position: absolute; z-index: 1; } .dropdown-content a { display: block; text-align: left; } .dropdown:hover .dropdown-content { display: block; } .dropbtn { background-color: #4CAF50; color: white; padding: 16px; font-size: 16px; border: none; cursor: pointer; } .dropbtn:hover { background-color: #3e8e41; } ``` jQuery代码: ```javascript $(document).ready(function() { $(".dropdown").hover(function() { $(this).children(".dropdown-content").slideDown("fast"); }, function() { $(this).children(".dropdown-content").slideUp("fast"); }); }); ``` 代码解释: - 首先,在HTML中创建一个包含菜单按钮和下内容的元素。 - 用CSS样式设置菜单按钮和下内容的样式。 - 使用jQuery代码设置当鼠标悬停在菜单按钮上时,下内容被显示出来。当鼠标移开时,下内容又被隐藏起来。具体实现是通过jQuery的`hover()`方法来完成的,方法的第一个参数是当鼠标进入时要执行的函数,第二个参数是当鼠标移出时要执行的函数。在这里,我们使用`slideDown()`和`slideUp()`方法来实现下和隐藏的效果,其中`"fast"`表示动画的速度,也可以使用其他值或者自定义速度。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值