- 相关推荐
利用JQuery动画实现滑动菜单项效果的步骤及代码
效果:
点击第二个菜单项后出现一个向上滑动的动画,控制margin-top底部另一个div中的文字
上移从而替换掉原有的文字。
原理其实不难无非就是css的控制加之jquery的代码
对docemnt中所有li绑定一个hover事件,事件中根据鼠标的状态(无非是移入与移除),
使用animate的动画方式使原有的div向上移70px,移出时再将页面效果变回原有的样子。
代码如下:
复制代码 代码如下:
$(function () {
var webNav = {
val: {
target: 0
},
init: function () {
$(".gnb ul li").on("hover", webNav.hover);
},
hover: function (e) {
if ($(this).index() == webNav.val.target) { return };
if (e.type == "mouseenter") {
$(this).find("a>p").stop(true, true).animate({ "margin-top": "-70px" }, 300);
} else if (e.type == "mouseleave") {
$(this).find("a>p").stop(true, true).animate({ "margin-top": "0px" }, 300);
}
}
};
webNav.init();
});
【利用JQuery动画实现滑动菜单项效果的步骤及代码】相关文章:
关jQuery弹出窗口简单实现代码-javascript编程06-07
jquery提交按钮的代码07-28
基于jQuery的固定表格头部的代码08-30
关于jQuery实现高亮显示的方法介绍08-20
JavaScript实现网页刷新代码段08-07
将php实现过滤UBB代码09-11
手绘效果图步骤09-03
手绘效果图技巧及步骤09-02
影视动画的场景设计步骤07-03