开发者

jQuery Cycle Plugin - Change Pager Anchors to Weekdays

I want to create a menu that sorts by days. Everything works except the pager won't output weekdays. 开发者_高级运维My code is as follows:

 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>';
        }
    }
});

It still defaults to numbers, however. Can someone point me in the right direction?


You have three errors. First, don't use document.write inline, second, you are nesting an extra options element. The whole thing passed to the cycle call are the options. Third, both idx and your array are zero indexed, so no need for the + 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>';
      }
  });
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜