How can I make the Bootstrap js carousel automatically cycle as soon as the page loads?

前端 未结 15 1595
花落未央
花落未央 2020-12-04 21:53

Using bootstrap.js version 2.02

I\'m trying to get the Twitter Bootstrap Carousel to automatically cycle as soon as someone visits my site. Right now, the auto cycl

15条回答
  •  隐瞒了意图╮
    2020-12-04 22:34

    A quick and dirty solution is to programmatically click the button on document ready:

    $(function() {
      $(".right.carousel-control").click();
    });
    

    BTW: make sure you load jQuery before the other scripts referring to $, right now you have two Uncaught ReferenceError: $ is not defined because you call $ on line 101 and 182, but jquery is first loaded on line 243.

    I would recommend using a tool like firebug or developer tool (chrome/safari) to catch these errors.

    EDIT: I think you already have a working solution, but because you use jquery before it's loaded it doesn't work.

提交回复
热议问题