室內設計1:廣告輪播

範例結果

六、#slider照片輪播,並且滑鼠移入時,停止輪播

為簡化程式,【$(‘.sliderTab a’)】重覆輸入,故將【var $sliderA = $(‘.sliderTab a’)

  //S3:【.slider a】事件
    var $sliderA = $('.sliderTab a')
      .click(function(){
            ...
            ...
            ...

【#slider】輪播程式

//S4:【#slider】 定時輪播
	var _speed = 1000;
	var $timer=window.setTimeout(sliderTimeFn,_speed);

	//S4-1:#slider滑鼠移入時,停止輪播
	$('#slider').hover(
		function(){ window.clearTimeout($timer);}
		,function(){ $timer = window.setTimeout(sliderTimeFn,_speed);}
	);

	//S4-2:#slider 輪播fn
	function sliderTimeFn(){
		var $clickIndex = $('.sliderTab a.on').index();
		$clickIndex = ($clickIndex+1) % $sliderA.length;
		$sliderA.eq($clickIndex).click();
		$timer = window.setTimeout(sliderTimeFn,_speed);
	}