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.