2010-01-16 63 views
3

我希望創建一個排序由天的菜單。除了尋呼機以外的一切工作將不會輸出工作日。我的代碼如下:的jQuery Cycle插件 - 更改尋呼機錨平日

var days = new Array("Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"); 
$('#main') 
.before('<div id="nav">') 
.cycle({ 
    fx:  'toss', 
    timeout: 0, 
    pager: '#nav', 
    options: { 
     pagerAnchorBuilder: function(i,el) { 
      return '<a href="#">'+document.write(days[i+1])+'</a>'; 
     } 
    } 
}); 

但是它仍然默認爲數字。有人能指引我朝着正確的方向嗎?

回答

3

你有三個錯誤。首先,不要使用內嵌的document.write,其次,您要嵌套一個額外的options元素。傳遞到cycle電話的全部是可選項。三,雙方idx和你的數組是零索引,所以不需要在+ 1

var days = ["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"]; 
$('#main') 
    .before('<div id="nav">') 
    .cycle({ 
     fx:  'toss', 
     timeout: 0, 
     pager: '#nav', 
     pagerAnchorBuilder: function(i,el) { 
      return '<a href="#">'+days[i]+'</a>'; 
     } 
    });