Home  >  Article  >  Web Front-end  >  The commonly used scrolling focus image effect code in shopping malls is simple and practical_jquery

The commonly used scrolling focus image effect code in shopping malls is simple and practical_jquery

WBOY
WBOYOriginal
2016-05-16 17:38:561040browse

There are many effects of this kind of mall on the Internet, but most of them are plug-ins, or the JS is too complicated to write, which seems to be difficult for children who are learning. This one looks simpler and easier to understand. If you need it, please watch it. You are also welcome to comment and post code (for convenience, you can just copy the code and use it without adding anything else):

Copy code Code As follows:




The commonly used scrolling effect in shopping malls. Simple and practical

< ;script type="text/javascript">
$(function(){
var len = $(".num > li").length;
var index = 0;
var adTimer;
$(".num li").mouseover(function(){
index = $(".num li").index(this);
showImg(index);
}).eq(0).mouseover();
//Slide in to stop animation, slide out to start animation.
$('.ad').hover(function(){
clearInterval( adTimer);
},function(){
adTimer = setInterval(function(){
showImg(index)
index ;
if(index==len){index=0; }
}, 3000);
}).trigger("mouseleave");
})
// Display different slides by controlling top
function showImg(index) {
var adHeight = $(".content .ad").height();
$(".slider").stop(true,false).animate({top : -adHeight*index}, 1000);
$(".num li").removeClass("on")
.eq(index).addClass("on");
}








  • < img src="http://pic.875.cn/upload/2013-01-24/1634016671.jpg" width="586" height="150"/>



  • < /li>


  • 1

  • 2

  • 3

  • 4

  • 5







The rendering is as follows:
The commonly used scrolling focus image effect code in shopping malls is simple and practical_jquery
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn