How to stop Bootstrap carousel from autosliding?

HtmlTwitter BootstrapCarousel

Html Problem Overview


I have built a bootstrap video carousel. It is working just fine but, the only problem I have is the carousel keeps sliding to the next slide after 5 seconds. How do I make it stop autosliding and only slide when the user clicks on the left or right arrows? I have pasted the code below.

    <div class="container">
		<div id="carousel-example-generic" class="carousel slide" data-ride="carousel" data-pause=hover>
			<!-- Indicators -->
			<ol class="carousel-indicators">
		  		<li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
	  			<li data-target="#carousel-example-generic" data-slide-to="1"></li>
		  		<li data-target="#carousel-example-generic" data-slide-to="2"></li>
			</ol>

			<!-- Wrapper for slides -->
			<div class="carousel-inner">
		  		<div class="item active">
		    		<div class="embed-responsive embed-responsive-16by9">
						<video class="embed-responsive-item" autoplay muted id="homevid">
							<source src="C:\Development Software\Sample Website\videos\Michael Vick 88 yard touchdown pass to DeSean Jackson.mp4" />
						</video>
					</div>
		    	<div class="carousel-caption">
		        
		    </div>
	  	</div>
		  	<div class="item">
		    	<div class="embed-responsive embed-responsive-16by9">
		    		<video class="embed-responsive-item" autoplay muted id="homevid">
		    			<source src="C:\Development Software\Sample Website\videos\Vick to Jeremy Maclin for 50 Yard TD.mp4" />
	    			</video>
    			</div>
		    	
		  	</div>
		  	<div class="item">
		    	<div class="embed-responsive embed-responsive-16by9">
		    		<video class="embed-responsive-item" autoplay muted id="homevid">
		    			<source src="C:\Development Software\Sample Website\videos\Michael Vick Scramble Plays vs Rams 2011.mp4" />
	    			</video>
    			</div>
		  </div>
	</div>

Html Solutions


Solution 1 - Html

By adding data-interval="false"

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

From the documentation

>Option - Interval - ..If false, carousel will not automatically cycle.

2021 Update

In Bootstrap 5 it is data-bs-interval="false"

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

Documentation

Solution 2 - Html

There are two ways.

1.

Update 2022: Bootstrap 5.x

In your HTML code, you need to use data-bs-interval="false"

<div id="your-carousel-id" class="carousel slide" data-bs-interval="false">
</div>
Bootstrap 4.x

In your HTML code, you need to use data-interval="false"

<div id="your-carousel-id" class="carousel slide" data-interval="false">
</div>

2.

If you want to do with the help of Jquery then you need to add.

// document ready
$(document).ready(function(){
    // Event for pushed the video
    $('#your-carousel-id').carousel({
        pause: true,
        interval: false
    });
});

Thanks :)

Solution 3 - Html

To stop the autoplay is by just removing the attribute data-ride=”carousel” from the htmlcode

<div id="carousel-example" class="carousel slide" data-ride="carousel">....</div>

There is another way to stop autoplay just add below code in your js file

$(window).load(function() {
    $('.carousel').carousel('pause'); 
});

Solution 4 - Html

Paste this code on your custom Javascript file.

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

Solution 5 - Html

In react-bootstrap in order to stop cycling you have to use

<Carousel interval={null}>
   ...
</Carousel>

Solution 6 - Html

There is an update on bootstrap https://getbootstrap.com/docs/5.1/components/carousel/

> data-bs-interval="false"

Solution 7 - Html

By adding data-interval="false" and removing data-ride="carousel" to the carousel id or class

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionuser3123222View Question on Stackoverflow
Solution 1 - Htmlim_brian_dView Answer on Stackoverflow
Solution 2 - HtmlVinod KumarView Answer on Stackoverflow
Solution 3 - HtmlAbhay SinghView Answer on Stackoverflow
Solution 4 - HtmlTariqul_IslamView Answer on Stackoverflow
Solution 5 - HtmlDahWaRView Answer on Stackoverflow
Solution 6 - HtmlIrinaPenzinaView Answer on Stackoverflow
Solution 7 - HtmlMohd AmirView Answer on Stackoverflow