【原创】【Jquery】仿亚马逊分类导航

本文介绍了一种使用JavaScript实现网页侧边栏导航功能的方法,包括鼠标悬停显示和离开隐藏的效果,通过HTML结构和CSS样式配合,实现动态显示不同分类的子菜单。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

由于css代码不是本人所写,所以本文中没有贴出css代码。

预览效果图:

2011060717235912.jpg

js代码:

/******************************************
Functional Description: common.js
Write By zhxhdean
CopyRight@zyue.com
*****************************************
*/
$(
function () {
//首页左侧导航
//鼠标移上
$(".index_menu div span").bind("mouseover", function () {
$(
".js_gdfl").css("display", "none");
$(
this).addClass("js_span_fl");
var idsp = $(this).attr("id").replace("js_sp_", "");
var topsp = 25 * parseInt(idsp);
if (idsp <= 6) {
$(
this).next("div").css({ "display": "block", "top": topsp + "px" });
}
else if (idsp == 7) {
$(
this).next("div").css({ "display": "block", "top": "150px" });
}
else {
$(
this).next("div").css({ "display": "block", "top": "163px" });
}

})
$(
".js_gdfl").bind("mouseover", function () {
$(
".js_gdfl").css("display", "none");
$(
this).prev().addClass("js_span_fl");
$(
this).css("display", "block");
})
//鼠标离开
$(".index_menu div span").bind("mouseout", function () {
$(
".js_gdfl").css("display", "none");
$(
this).removeClass("js_span_fl");
})
$(
".js_gdfl").bind("mouseout", function () {
$(
".js_gdfl").css("display", "none");
$(
this).prev().removeClass("js_span_fl");
})
})

html部分核心代码:

 
<div class="js_inex_menu_div">
<span id="js_sp_0"><a href="#">精品婚纱 &gt;</a></span>
<div class="js_gdfl">
<ul class="tc_menu">
<li class="tczl">款 式:</li><li class="kslx"><a href="#">抹胸型</a><a href="#">一字肩</a><a
href="#">吊带型</a><a href="#">挂脖型</a><a href="#">深V领</a><a href="#">冬季婚纱</a> <a href="#">
孕妇婚纱
</a></span></li>
</ul>
<ul class="tc_menu bj">
<li class="tczl">裙 摆:</li><li class="kslx"><a href="#">抹胸型</a><a href="#">一字肩</a><a
href="#">吊带型</a><a href="#">挂脖型</a><a href="#">深V领</a><a href="#">冬季婚纱</a> <a href="#">
孕妇婚纱
</a></span></li>
</ul>
</div>
</div> 

转载于:https://www.cnblogs.com/zhxhdean/archive/2011/06/07/2074504.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值