2013-12-21 56 views
1

下面的代碼我使用:如何使jQuery的滑塊移動每5秒自動

jsfiddle

HTML部分:只

<div id="paginationdemo">     
<div id="p1" class="pagedemo _current" style=""> 
    <a href='#' class="link_title"> 
    <h3>Cu mei liber viderer mazim neglegentur</h3> 
    <img src='http://s2.goodfon.com/wallpaper/previews/581412-n.jpg' width='450' height='250'> 
     <p style="margin:2px; text-align:left; text-decoration:none">Cu mei liber viderer, mazim neglegentur eam ad. Quis scriptorem te usu, nonumes appetere eam in. Vix ridens consulatu an <a href='#' class="read_more"> (...Lire la suite)</a></p> 
    </a> 
</div> 
<div id="p2" class="pagedemo" style="display:none;"> 
    <a href='#' class="link_title"> 
    <h3>Graecis persequeris ius no</h3> 
    <img src='http://s2.goodfon.com/wallpaper/previews/414923-n.jpg' width='450' height='250'> 
     <p style="margin:2px; text-align:left; text-decoration:none">Graecis persequeris ius no, fugit apeirian sea te. Quo iusto maiorum ad, ius te ancillae noluisse. Purto decore duo <a href='post.php' class="read_more"> (...Lire la suite)</a></p> 
     </a> 
</div> 
.... 
<div id="paginationDiv"></div> 
</div>  

滑塊移動,當我點擊分頁號碼。

我該如何讓它每5秒自動移動一次並更改主題?

回答

0

試試這個

var lis = $(".jPag-pages li") 
     console.log(lis.length) 
     currentHighlight = 0; 
     N = 5;//interval in seconds 
    setInterval(function() { 
     console.log(currentHighlight) 
     currentHighlight = (currentHighlight+1) % lis.length; 
     lis.eq(currentHighlight).click(); 
    }, N * 1000); 

DEMO

+0

感謝的人!它正在工作,這就是我一直在尋找的。歡呼:) – facemoi

+0

如果我想滑塊繼續循環。一旦達到currentHighlight == 14並從currentHighlight == 1重新啓動,等等..? – facemoi

+0

k我會看到並更新你 –