Picture Carousel (Jquery)

Source: Internet
Author: User
Tags prev

Yesterday in the blog Park to see Imwtr wrote the picture Carousel (Fade) of the article, feel whether they can be written in the form of jquery plug-in, but also convenient after the time if necessary can be used directly.

After the adjustment and integration, completed the first version of the jquery.carousel.js, followed by a brief introduction to the interface and features:

1. Interface

2. function

Click Switch, forward switch, back switch, timed switch

3. Function realization

(1), test code

$(function () {    vardata =[{src:' Content/home/1.jpg ', info: ' 1.jpg Click on image to navigate to About.html ', alt: ', href: ' about.html '}, {src:' Content/home/2.jpg ', info: ' 2.jpg '}, {src:' Content/home/3.jpg ', info: ' 3.jpg '}, {src:' Content/home/4.jpg ', info: ' 4.jpg '}, {src:' Content/home/5.jpg ', info: ' 5.jpg '}, {src:' Content/home/6.jpg ', info: ' 6.jpg '}, {src:' Content/home/7.jpg ', info: ' 7.jpg ' }    ]; varCaro = $ (' #container '). Carousel ({data: [],//data,' Info-opacity ': 0, Height:300, Width:400, Interval:2000,        ' Default-index ': 2,        ' Show-index ':true,        ' Nav-width ': 20,        ' Nav-color ': ' Red ', OnChange:function(item) {}}); //Caro.carousel (' clear ');Caro.carousel (' LoadData ', data); varindex = Caro.carousel (' GetIndex '); vardata = Caro.carousel (' GetData ', index); $(' #next '). Click (function() {Caro.carousel (' Next ');    }); $(' #prev '). Click (function() {Caro.carousel (' Prev '); });});

(2), code detailed introduction

The default property contains the following sections:

$.fn.carousel.defaults = {        ' Data ': [],        ' Height ': ' Auto ',        ' Width ': ' Auto ',        ' Info-background-color ': ' Black ',//Display information background color' Info-height ': 40,//Displays the height of the information background' Info-opacity ': 0.1,//Show transparency of information backgrounds' Info-style ': ' Font-size:12pt;color:black; ',//Display Information Styles' Default-index ': 0,//default ordinal at initial        //' nav-width ': 10,//left/right navigation width, not set to half of HEIHHT by default (height not auto, otherwise)' Nav-color ': ' #f6fafa ',//left and right side navigation color' Interval ': 5000,//Automatic switching cycle' Show-index ':false,//the serial number on the lower right side button is not displayed by default' Auto ':true,//Automatic Switching' Border ':true,//Show Border' Margin ': ' 30px auto ', OnChange:function(item) {}};

Methods include

$.fn.carousel.methods ={options:function(JQ) {return$.data (jq[0], ' Carousel '). Options; }, clear:function(JQ) {cleardata (jq[0]); }, LoadData:function(JQ, data) {ClearData (jq[0]); BindingData (jq[0], data); }, Prev:function(JQ) {varOptions = $.data (jq[0], ' Carousel '). Options; varPanel = $ ('. My-panel ', jq[0]);        Prev (panel, options); }, Next:function(JQ) {varOptions = $.data (jq[0], ' Carousel '). Options; varPanel = $ ('. My-panel ', jq[0]);        Next (Panel, options); }, GetIndex:function(JQ) {varOptions = $.data (jq[0], ' Carousel '). Options; returnoptions[' Now-index ']; }, GetData:function(JQ, index) {varOptions = $.data (jq[0], ' Carousel '). Options; returnOptions.data[index]; }    };

Finally, the demo

Due to the limited level, the code will inevitably appear wrong or imperfect situation, but also please the Aunt pointed out ~

Picture Carousel (Jquery)

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.