jquery 简单图片导航插件jquery.imgNav.js

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

jquery 简单图片导航插件jquery.imgNav.js

  2020-05-12 我要评论

熟悉jquery的家伙大概花个5到10分钟就可以搞定了吧。由于这种导 航效果比较通用,LEVIN顺手写了个 jquery插件~

如果你的网站也需要类似的效果,大可拿去直接用或者扩展下:)

如果你也想尝试将某些可重用功能封 装成jquery插件,别忘了看看一般的jquery插件开发过程,另外还有偶的一个jquery插件模板。

复制代码 代码如下:

;(function($) {
// Private functions.
var p = {};
p.showC = function(opts) {
///<summary>show content of a specified navigation</summary>
p._clist.hide().filter(opts.filter).show();
}; //showNav
p.onNav = function(evt) {
p._i=$(this);
p._alist.removeClass(p._opts.on);
p._i.addClass(p._opts.on);
p.showC({ filter:p._i.attr("href") });
return false;
}; //onClick
//main plugin body
$.fn.imgNav = function(options) {
// Set the options.
options = $.extend({}, $.fn.imgNav.defaults, options);
p._opts = options;
// Go through the matched elements and return the jQuery object.
return this.each(function() {
p._alist = $("a", this);
p._clist = $(p._opts.navc);
p._alist.click(p.onNav);
});
};
// Public defaults.
$.fn.imgNav.defaults = {
on: 'on',
off: 'off',
navc: '.navc'//nav content selector
};
})(jQuery);

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们