JQuery makes concise image carousel effects, and jquery carousel

Source: Internet
Author: User

JQuery makes concise image carousel effects, and jquery carousel

Demo diagram:

Core code:

$ (Document ). ready (function () {var $ iBox = $ ('. imgBox '), $ iNum = $ ('. imgNum '), // Cache Optimization indexImg = 1, // initial subscript totalImg = 4, // total number of images imgSize = 300, // image size width moveTime = 1100, // switch the animation time setTime = 2500, // The intermediate pause time clc = null; function moveImg () {if (indexImg! = TotalImg) {$ iBox. animate ({left:-(indexImg * imgSize) + 'px '}, moveTime); $ iNum. removeClass ('mark-color '). eq (indexImg ). addClass ('mark-color'); indexImg ++;} else {indexImg = 1; $ iNum. removeClass ('mark-color '). eq (indexImg-1 ). addClass ('mark-color'); $ iBox. animate ({left: 0}, moveTime) ;}}$ iNum. hover (function () {$ iBox. stop (); // end the current animation clearInterval (clc); // pause the loop $ iNum. removeClass ('mark-color'); $ (this ). addClass ('mark-color'); indexImg = $ (this ). index (); $ iBox. animate ({left:-(indexImg * imgSize) + 'px'}, 500) ;}, function () {clc = setInterval (moveImg, setTime );}); clc = setInterval (moveImg, setTime );});

The above is all the content of this article. I hope you will like it.

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.