"Slider: less than 2 pictures, hide the navigation"
Bootstrap 4.0.0 Snippet by ashutosh123

<link href="//maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script> <script src="//code.jquery.com/jquery-1.11.1.min.js"></script> <!------ Include the above in your HEAD tag ----------> <section class="page-section"> <div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel"> <ol class="carousel-indicators"> <li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li> <li data-target="#carouselExampleIndicators" data-slide-to="1"></li> <li data-target="#carouselExampleIndicators" data-slide-to="2"></li> </ol> <div class="carousel-inner" role="listbox"> <div class="carousel-item active"> <img class="d-block img-fluid" src="http://lorempixel.com/output/food-q-c-1920-560-5.jpg" alt="First slide"> <a href="#" class="carousel-caption d-none d-md-block"> <span>Dachzeile</span> <h3>First slide label</h3> <p>Nulla vitae elit libero, a pharetra augue mollis interdum.</p> </a> </div> <div class="carousel-item"> <img class="d-block img-fluid" src="http://lorempixel.com/output/nature-q-c-1920-560-8.jpg" alt="Second slide"> <a href="#" class="carousel-caption d-none d-md-block"> <span>Dachzeile</span> <h3>Second slide label</h3> <p>Nulla vitae elit libero, a pharetra augue mollis interdum.</p> </a> </div> <div class="carousel-item"> <img class="d-block img-fluid" src="http://lorempixel.com/output/nature-q-c-1920-560-3.jpg" alt="Third slide"> <a href="#" class="carousel-caption d-none d-md-block"> <span>Dachzeile</span> <h3>Third slide label</h3> <p>Nulla vitae elit libero, a pharetra augue mollis interdum.</p> </a> </div> </div> <a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev"> <span class="carousel-control-prev-icon" aria-hidden="true"></span> <span class="sr-only">Previous</span> </a> <a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next"> <span class="carousel-control-next-icon" aria-hidden="true"></span> <span class="sr-only">Next</span> </a> </div> </section>
$(document).ready(function slider__pictureNumber() { var $elem = $('.carousel-inner'); var $slider = $elem.closest(".carousel"); var counter = $("div", $elem).length; var carouselIndicators = $slider.find('.carousel-indicators'); var carouselControlPrev = $slider.find('.carousel-control-prev'); var carouselControlNext = $slider.find('.carousel-control-next'); if (counter < 2) { carouselIndicators.hide(); carouselControlPrev.hide(); carouselControlNext.hide(); } });

Related: See More


Questions / Comments: