Jquery simple image navigation plug-in jquery. imgNav. js

Source: Internet
Author: User

It takes about five to ten minutes to get familiar with jquery. LEVIN successfully wrote a jquery plug-in because this pilot effect is quite common ~

If your website needs a similar effect, you can use it directly or expand it :)

If you want to encapsulate some reusable functions into jquery plug-ins, do not forget to take a look at the general jquery plug-in development process, and even have a jquery plug-in template.

Copy codeThe Code is as follows:
; (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 );

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.