我想创建一个按天分类的菜单。一切正常,除了寻呼机不会输出工作日。我的代码如下:
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>';
}
}
});
但它仍默认为数字。有人能指出我正确的方向吗?
答案 0 :(得分: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>';
}
});