[jquery] Preventing twitter bootstrap carousel from auto sliding on page load

So is there anyway to prevent twitter bootstrap carousel from auto sliding on the page load unless the next or previous button is clicked?

Thanks

This question is related to jquery twitter-bootstrap carousel

The answer is


Or if you're using Bootstrap 3.0 you can stop the cycling with data-interval="false" for instance

<div id="carousel-example-generic" class="carousel slide" data-interval="false">

Other helpful carousel data attributes are here -> http://getbootstrap.com/javascript/#carousel-usage


--Use data-interval="false" to stop automatic slide --Use data-wrap="false" to stop circular slide

...

Below are the list of parameters for bootstrap carousel. Like Interval, pause, wrap:

enter image description here

For more details refer this link:

http://www.w3schools.com/bootstrap/bootstrap_ref_js_carousel.asp

Hope this will help you :)

Note: This is for further help. I mean how you can customise or change default behaviour once carousel is loaded.


  • Use data-interval="false" to stop automatic slide
  • Use data-wrap="false" to stop circular slide

if you're using bootstrap 3 set data-interval="false" on the HTML structure of carousel

example:

<div id="carousel-example-generic" class="carousel slide" data-ride="carousel" data-interval="false">

The problem with carousel automatically sliding after prev/next button press is solved.

$('.carousel').carousel({
    pause: true,
    interval: false
});

GitHub commit 78b927b


add this to your coursel div :

data-interval="false"

For Bootstrap 4 simply remove the 'data-ride="carousel"' from the carousel div. This removes auto play at load time.

To enable the auto play again you would still have to use the "play" call in javascript.


Actually, the problem is now solved. I added the 'pause' argument to the method 'carousel' like below:

$(document).ready(function() {      
   $('.carousel').carousel('pause');
});

Anyway, thanks so much @Yohn for your tips toward this solution.


I think maybe you should go to check the official instruction about carousel, for me, i have not found answer above, because of multiple versions of bootstrap, I'm using b4-alpha and i want the autoplay effect stop.

$(document).ready({
    pause:true,
    interval:false
});

this script does not make any effect while mouse leave that page, exactly carousel area. go to official definition and find those :

enter image description here

So you will find why.if carousel page onmouseover event triggered, page will pause, while mouse out of that page, it'll resume again.

So, if you want a page stop forever and rotate manually, you can just set data-interval='false'.


Examples related to jquery

How to make a variable accessible outside a function? Jquery assiging class to th in a table Please help me convert this script to a simple image slider Highlight Anchor Links when user manually scrolls? Getting all files in directory with ajax Bootstrap 4 multiselect dropdown Cross-Origin Read Blocking (CORB) bootstrap 4 file input doesn't show the file name Jquery AJAX: No 'Access-Control-Allow-Origin' header is present on the requested resource how to remove json object key and value.?

Examples related to twitter-bootstrap

Bootstrap 4: responsive sidebar menu to top navbar CSS class for pointer cursor How to install popper.js with Bootstrap 4? Change arrow colors in Bootstraps carousel Search input with an icon Bootstrap 4 bootstrap 4 responsive utilities visible / hidden xs sm lg not working bootstrap.min.js:6 Uncaught Error: Bootstrap dropdown require Popper.js Bootstrap 4 - Inline List? Bootstrap 4, how to make a col have a height of 100%? Bootstrap 4: Multilevel Dropdown Inside Navigation Change arrow colors in Bootstraps carousel How to make a owl carousel with arrows instead of next previous Owl Carousel, making custom navigation Bootstrap change carousel height How can I change the width and height of slides on Slick Carousel? How to make Bootstrap carousel slider use mobile left/right swipe Bootstrap 3 Carousel Not Working Bootstrap carousel multiple frames at once Carousel with Thumbnails in Bootstrap 3.0 Fixed height and width for bootstrap carousel