jQuery Cycle 插件 - 将寻呼机锚点更改为工作日

发布于 2024-08-17 16:19:18 字数 479 浏览 8 评论 0原文

我想创建一个按天排序的菜单。一切正常,除了寻呼机不会输出工作日。我的代码如下:

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

但是,它仍然默认为数字。有人能指出我正确的方向吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

孤独陪着我 2024-08-24 16:19:18

你有三个错误。首先,不要内联使用 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>';
      }
  });

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>';
      }
  });
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文