4.1 作業(yè)

$(fuction()){

? var $li = $('.slide_pics li');

? var len = $li.length;

? var nextli = 0;

? var nowli = 0;

? var $prev = $('.prev');

? var $next = $('.next');

? var timer = null;

?

? $li.not(':first').css({left:800});

?

? $li.each(function(index)){

? var $sli = $('<li></li>');

? if(index == 0){

? ? $sli.addClass('active');

? ? }

? ? $sli.appendTo('.points');

? ? })

? ?

? ? $points = $('.poinnts li');

? ?

? ? $points.click(function()){

? ? nextli = $(this).index

? ? if(nextli == nowli){

? ? return;

? ? }

? ? move();

? ? $(this).addClass('active').siblings().renoveClass('active');

? ? });

? ? $prev.click(function()){

? ? nextli--;

? ? move();

? ? $points.eq(nextli).addClass('active').siblings().removeClass('actve');

? ? });

? ? $next.click(function()){

? ? nextli--;

? ? move();

? ? $points.eq(nextli).addClass('active').siblings().removeClass('actve');

? ? });

? ?

? ? $('.slide').hover(function()){

? ? clearInterval(timer);

? ? },function(){

? ? timer = setInterval(autoplay,3000);

? ? });

? ?

? ? timer = setInterval(autoplay,3000);

? ?

? ? function autoplay(){

? ? ? nextli++;

? ? ? move();

? ? $points.eq(nextli).addClass('active').siblings().removeClass('actve');

? ? ?

? ? }

? ?

? ? function move(){

? ? if(nextli < 0){

? ? nextli = len - 1;

? ? nowli = 0;

? ? $li.eq(nextli).css({left:-800});

? ? $li.eq(nowli).stop().stop().animate({left:400});

? ? $li.eq(nowli).stop().stop().animate({left:0});

? ? nowli = nextli;

? ? return;

? ? }

? ?

? ? if(nextli > len - 1){

? ? nextli = 0;

? ? nowli = len - 1;

? ? $li.eq(nextli).css({left:-800});

? ? $li.eq(nowli).stop().stop().animate({left:400});

? ? $li.eq(nowli).stop().stop().animate({left:0});

? ? nowli = nextli;

? ? return;

? ? }

? ? if(nextli > nowli){

? ? $li.eq(nextli).css({left:600});

? ? $li.eq(nowli).stop().animate({left: 800});

? ? }else{

? ? $li.eq(nextli).css({left: -800});

? ? $li.eq(nowli).stop().animate({left: 800});

? ? }

? ? $li.eq(nextli).stop().animate({left: 0});

? ? nowli = nextli;

? ? }

? ? })

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容