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 cycling works only after you click one of the cycle buttons at least once.
I want the carousel to begin cycling at the interval right away.
Does anyone know how to do this?
My site is hotairraccoon.com
You'll see how after you click the carousel once, it begins to cycle every 5 seconds or so, but I don't want the click to be required to reveal carousel content.
Thanks!
There is one more way to automatically cycle the bootstrap carousel.
use
data-ride="carousel"
attribute. It tells the bootstrap to begin animating the carousel immediately when the page loads.Not sure if you got this sorted out, but I was having that problem as well. I resolved it by wrapping the carousel interval setting in a function like this:
A quick and dirty solution is to programmatically click the button on document ready:
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.
Try to initialize your carousel like this:
The jquery.js file must load before the bootstrap.js, whether they are placed in the head tags or at the end of your file.
if none of those solutions work for you. try this: