其实我一直奇怪为什么jquery的书籍还能卖出去。当两年前我发现jquery时,在网上随便搜索几篇文章,然后在把它的文档下下来一看,呵呵,差不多一切就在这里。不用特意去买任何书籍。
易用且功能强大,jquery真的让人爱不释手。
最近工作做一个功能。受制于原来某人的设计以及编程限制,总是想办法跳过去,不去理会原有的东西。此话不多讲。只是在想问题的过程中想到的伸缩式菜单。回家就随便试一试。
于是就有了如下,用jquery开发的jquery插件式伸缩菜单。其实超级简单。
<html>
<head>
<title>这只是一个测试</title>
<script src="jquery-1.3.2.min.js"></script>
<style>
.orger {
position: relative;
background-color: yellow;
height: 77px;
width: 200px;
border: 1px solid blue;
overflow: hidden;
}
.newer {
position: relative;
background-color: yellow;
height: 190px;
width: 200px;
border: 1px solid blue;
overflow: auto;
}
</style>
</head>
<body>
<div style="position: absolute; top: 10px; left: 500px;">
<div style="background-color: blue; color: white; text-align: center;"> 菜单 </div>
<div id="theMenu">
<a href="http://www.baidu.cn" target="detail">百度</a><br>
<a href="http://www.163.com" target="detail">163</a><br>
<a href="http://www.126.com" target="detail">126</a><br>
<a href="http://www.yahoo.com.cn" target="detail">雅虎</a><br>
<a href="http://www.baidu.cn" target="detail">百度</a><br>
<a href="http://www.163.com" target="detail">163</a><br>
<a href="http://www.126.com" target="detail">126</a><br>
<a href="http://www.yahoo.com.cn" target="detail">雅虎</a><br>
<a href="http://www.baidu.cn" target="detail">百度</a><br>
<a href="http://www.163.com" target="detail">163</a><br>
<a href="http://www.126.com" target="detail">126</a><br>
<a href="http://www.yahoo.com.cn" target="detail">雅虎</a><br>
<a href="http://www.baidu.cn" target="detail">百度</a><br>
<a href="http://www.163.com" target="detail">163</a><br>
<a href="http://www.126.com" target="detail">126</a><br>
<a href="http://www.yahoo.com.cn" target="detail">雅虎</a><br>
</div>
</div>
<div style="height: 100px;">
</div>
<div style="">
<iframe id="detail" name="detail" src="http://www.google.cn" style="width: 100%; height: 100%"></iframe>
</div>
</body>
<script>
jQuery.fn.extend({
expendMenu: function() {
return this.each(function() {
$(this).attr("class", "orger");
//对鼠标进出进行事件响应
$(this).mouseover(function() {
$(this).attr("class", "newer");
});
$(this).mouseout(function() {
$(this).attr("class", "orger");
});
//对菜单链接点击进行响应
$(this).find("a").click(function() {
$(this).parent().attr("class", "orger");
});
});
},
});
$("#theMenu").expendMenu();
</script>
</html>
可以发现,开发一个jquery插件的过程是如此简单。jQuery.fn.extend() 中加入你想要的功能
分享到:
相关推荐
jQuery 手风琴插件导航滑动伸缩型菜单 jQuery 手风琴插件导航滑动伸缩型菜单 jQuery 手风琴插件导航滑动伸缩型菜单 jQuery 手风琴插件导航滑动伸缩型菜单
jQuery页面左侧伸缩下拉导航菜单.zip
jQuery滑动侧边栏实现多级菜单插件jSide.zip
jQuery左侧伸缩导航菜单基于jquery-1.8.3.min.js制作,点击展开收缩效果,包括无缓动—展开隐藏、无缓动—百叶窗、滑动—展开隐藏、滑动—百叶窗等四种伸缩特效。
主要介绍了jQuery实现的动态伸缩导航菜单,实例分析了jQuery鼠标事件及animate、hide等方法的使用技巧,需要的朋友可以参考下
比较好的jquery的菜单显示,适合于网站开发的菜单显示!
jQuery多功能搜索框插件下拉菜单选择代码.rar
基于jQuery伸缩型菜单一例 基于jQuery伸缩型菜单一例
timeline插件是一款非常简洁实用的jQuery时间轴插件,jQuery可伸缩时间轴代码。
js/jquery伸缩窗口菜单,共4个,适合网上商城
jquery 菜单 伸缩 有三个皮肤 有实例
jQuery 伸缩菜单(典型、简单的实例) jQuery 伸缩菜单(典型、简单的实例) jQuery 伸缩菜单(典型、简单的实例)
从网上收集的,没有做任何改动,个人觉得挺好的,分享给大家。
自己用jquery写个一个侧边菜单,用于学习交流用
jquery插件colResizable实现表格列可拖拽伸缩表格大小
jQuery网站右侧固定可伸缩浮动菜单代码是一款开始时只显示一个按钮,点击按钮时可以垂直展开所有的菜单项,展开后点击按钮又可以收起网页右侧菜单栏的效果。
带伸缩的下拉菜单,JUQERY坚形的,效果动态式
鼠标移动到导航上后,导航内容向左滑出隐藏
jQuery页面左侧伸缩下拉导航菜单,简单的伸缩导航菜单