1

上次我有一个很好的经验问一个问题,并认为我会回来寻求更多帮助。你们太棒了。先感谢您。

我正在使用一个特色帖子滑块,它会自动通过 4 个帖子。我想添加下一个和上一个按钮。我知道我需要将某种 .click() 事件附加到 #movers-next 和 #movers-previous 但到目前为止我所尝试的一切都导致性能参差不齐。

你能帮我编写一个稳定的循环变量“curclicked”的方法吗?(注意:.stripNav ul li a 由插件自动生成,作为循环帖子的一种方式)

谢谢你。

<script type="text/javascript">
var theInt = null;
var $crosslink, $navthumb;
var curclicked = 0;

theInterval = function(cur){
 clearInterval(theInt);

 if( typeof cur != 'undefined' )
  curclicked = cur;

 $crosslink.removeClass("active-thumb");
 $navthumb.eq(curclicked).parent().addClass("active-thumb");
  jQuery(".stripNav ul li a").eq(curclicked).trigger('click');

 theInt = setInterval(function(){
  $crosslink.removeClass("active-thumb");
  $navthumb.eq(curclicked).parent().addClass("active-thumb");
  jQuery(".stripNav ul li a").eq(curclicked).trigger('click');
  curclicked++;
  if( 6 == curclicked )
   curclicked = 0;

 }, 8000);
};



jQuery(function(){

 jQuery("#main-photo-slider").codaSlider();

 $navthumb = jQuery(".nav-thumb");
 $crosslink = jQuery(".cross-link");

 $navthumb
 .click(function() {
  var $this = jQuery(this);
  theInterval($this.parent().attr('href').slice(1) - 1);
  return false;
 });

 theInterval();
});

<div id="page-wrap">
<div class="slider-wrap">
 <div id="main-photo-slider" class="csw">
  <div class="panelContainer">

<div class="panel" title="Panel 1">
 <div class="wrapper">
  <img src='http://thevarsitysquad.com/wordpress/love2eat/wp-content/files_flutter/th_b700d8c1271c49208e0f9230a1a215f2_1257387907thai_cuisine.jpg' />      <div class="photo-meta-data">
   Etiam eu mauris augue       <p>Suscipit a aliquet a, gravida non erat. Integer euismod felis nec&#8230;</p>
  </div>
 </div>
</div>
<div class="panel" title="Panel 2">
 <div class="wrapper">
  <img src='http://thevarsitysquad.com/wordpress/love2eat/wp-content/files_flutter/th_b700d8c1271c49208e0f9230a1a215f2_1257387756EthnicCuisine.jpg' />      <div class="photo-meta-data">
   Etiam eu mauris augue       <p>Suscipit a aliquet a, gravida non erat. Integer euismod felis nec&#8230;</p>
  </div>
 </div>
</div>
<div class="panel" title="Panel 3">
 <div class="wrapper">
  <img src='http://thevarsitysquad.com/wordpress/love2eat/wp-content/files_flutter/th_b700d8c1271c49208e0f9230a1a215f2_1257386373slider-primary.jpg' />      <div class="photo-meta-data">
   Etiam eu mauris augue       <p>Suscipit a aliquet a, gravida non erat. Integer euismod felis nec&#8230;</p>
  </div>
 </div>
</div>
<div class="panel" title="Panel 4">
 <div class="wrapper">
  <img src='http://thevarsitysquad.com/wordpress/love2eat/wp-content/files_flutter/th_b700d8c1271c49208e0f9230a1a215f2_1257387711cuisine.jpg' />      <div class="photo-meta-data">
   Etiam eu mauris augue       <p>Suscipit a aliquet a, gravida non erat. Integer euismod felis nec&#8230;</p>
    </div>
   </div>
  </div>
 </div>
</div>

<div id="movers-row">
<a id="movers-previous" href="#"><img src="http://thevarsitysquad.com/wordpress/love2eat/wp-content/themes/eater/img/slider-button-previous.gif" /></a>
 <div><a href="#1" class="cross-link"><img src='http://thevarsitysquad.com/wordpress/love2eat/wp-content/files_flutter/th_b700d8c1271c49208e0f9230a1a215f2_1257387907thai_cuisine.jpg' /></a></div>
 <div><a href="#2" class="cross-link"><img src='http://thevarsitysquad.com/wordpress/love2eat/wp-content/files_flutter/th_b700d8c1271c49208e0f9230a1a215f2_1257387756EthnicCuisine.jpg' /></a></div>
 <div><a href="#3" class="cross-link"><img src='http://thevarsitysquad.com/wordpress/love2eat/wp-content/files_flutter/th_b700d8c1271c49208e0f9230a1a215f2_1257386373slider-primary.jpg' /></a></div>
 <div><a href="#4" class="cross-link"><img src='http://thevarsitysquad.com/wordpress/love2eat/wp-content/files_flutter/th_b700d8c1271c49208e0f9230a1a215f2_1257387711cuisine.jpg' /></a></div>
 <a id="movers-next" href="#"><img src="http://thevarsitysquad.com/wordpress/love2eat/wp-content/themes/eater/img/slider-button-next.jpg" /></a>
 </div>

 </div>
 </div>  
4

0 回答 0