Javascript jQuery循环转到选项

Javascript jQuery循环转到选项,javascript,jquery,cycle,jquery-cycle,Javascript,Jquery,Cycle,Jquery Cycle,我的Js: 但是撞坏了我的导航按钮。当我通过DevTools检查时,出现以下错误: $container.children().each(function(i) { // create input $('<li><a href="#" rel="'+ i +'">'+ i +'</a></li>') // append it to button container

我的Js:

但是撞坏了我的导航按钮。当我通过DevTools检查时,出现以下错误:

    $container.children().each(function(i) { 
        // create input 
        $('<li><a href="#" rel="'+ i +'">'+ i +'</a></li>') 
            // append it to button container 
            .appendTo(bc) 
            // bind click handler 
            .click(function() { 
                // cycle to the corresponding slide 
                $container.cycle(i); 
                return false; 
            }); 
    }); 
我没有发现我的问题


如何添加可单击的按钮?

从您指定的链接中,我可以看到唯一的区别是您没有将循环对象返回值保存在变量中,如:

$container is not defined 
您的代码应该是:

var $container = $('#container').cycle({ 
    fx:     'scrollHorz', 
    speed:   300, 
    timeout: 0 
}); 
var $container = $('#container').cycle({ 
    fx:     'scrollHorz', 
    speed:   300, 
    timeout: 0 
}); 
var $container = $("#front_events").cycle({
   fx:      'scrollHorz',
   next:   '.next',
   prev: '.prev',
   speed:500,
   timeout: 0,
   ......