鼠标悬浮显示二级菜单效果的jquery实现
作者:bea
1.布局: <div class="show"> <img src="~/images/head_icon.png" /> <div class="drop" style=" display:none; z-index:80000" id="profileMenu"> <ul> <li> <a class="pass" style="cursor: pointer" href='#'> <spa
1.布局:
<div class="show">
<img src="~/images/head_icon.png" />
<div class="drop" style=" display:none; z-index:80000" id="profileMenu">
<ul>
<li>
<a class="pass" style="cursor: pointer"
href='#'>
<span>修改密码</span>
</a>
</li>
<li>
<a class="quit" style="cursor: pointer"
href='#'
><span>退出</span></a>
</li>
</ul>
</div>
</div>
2.js控制:
function dropMenu(obj) {
$(obj).each(function () {
var theSpan = $(this);
var theMenu = theSpan.find(".drop");
var tarHeight = theMenu.height();
theMenu.css({ height: 0, opacity: 0 });
var t1;
function expand() {
clearTimeout(t1);
//theSpan.find('a').addClass("selected");
theMenu.stop().show().animate({ height: tarHeight, opacity: 1 }, 200);
}
function collapse() {
clearTimeout(t1);
t1 = setTimeout(function () {
// theSpan.find('a').removeClass("selected");
theMenu.stop().animate({ height: 0, opacity: 0 }, 200, function () {
$(this).css({ display: "none" });
});
}, 250);
}
theSpan.hover(expand, collapse);
theMenu.hover(expand, collapse);
});
}
有用 | 无用
<div class="show">
<img src="~/images/head_icon.png" />
<div class="drop" style=" display:none; z-index:80000" id="profileMenu">
<ul>
<li>
<a class="pass" style="cursor: pointer"
href='#'>
<span>修改密码</span>
</a>
</li>
<li>
<a class="quit" style="cursor: pointer"
href='#'
><span>退出</span></a>
</li>
</ul>
</div>
</div>
2.js控制:
function dropMenu(obj) {
$(obj).each(function () {
var theSpan = $(this);
var theMenu = theSpan.find(".drop");
var tarHeight = theMenu.height();
theMenu.css({ height: 0, opacity: 0 });
var t1;
function expand() {
clearTimeout(t1);
//theSpan.find('a').addClass("selected");
theMenu.stop().show().animate({ height: tarHeight, opacity: 1 }, 200);
}
function collapse() {
clearTimeout(t1);
t1 = setTimeout(function () {
// theSpan.find('a').removeClass("selected");
theMenu.stop().animate({ height: 0, opacity: 0 }, 200, function () {
$(this).css({ display: "none" });
});
}, 250);
}
theSpan.hover(expand, collapse);
theMenu.hover(expand, collapse);
});
}
有用 | 无用
猜你喜欢
您可能感兴趣的文章:
- javascript根据时间生成m位随机数最大13位
- D3.js 从P元素的创建开始(显示可加载数据)
- jquery 获取 outerHtml 包含当前节点本身的代码
- 如何调试异步加载页面里包含的js文件
- fckeditor粘贴Word时弹出窗口取消的方法
- js中style.display=""无效的解决方法
- Js实现网页键盘控制翻页的方法
- javascript实现iframe框架延时加载的方法
- js中iframe调用父页面的方法
- js防止页面被iframe调用的方法
- escape函数解决js中ajax传递中文出现乱码问题
- js防止DIV布局滚动时闪动的解决方法
- js实现window.open不被拦截的解决方法汇总
- 一个JavaScript获取元素当前高度的实例
- JS 实现列表与多选框选择附预览动画
- 一个JavaScript操作元素定位元素的实例
- js实现ArrayList功能附实例代码
- JQuery 实现在同一页面锚点链接之间的平滑滚动
- js中的json对象详细介绍