Multiple Carousel on the same page

Asked

Viewed 259 times

0

By inserting multiple Carousel , by clicking on any other Carousel, only the first changes.

Someone can help me?

<section>
    <div class="row">
        <div class="col-lg-6">
            <h3>Titulo nivel 3</h3>
            <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
            tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
            quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
            consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
            cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
            proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
        </div>
        <div class="col-lg-6">
            <!-- CAROUSEL-->    
                 <div id="myCarousel" class="carousel slide" data-ride="carousel">
                    <div class="carousel-inner" role="listbox">
                         <div class="item active">
                            <img src="" alt="Chania">
                            <div class="carousel-caption">
                                <h3>Lorem ipsum dolor sit amet</h3>
                                <p>Details of Slide 1. Lorem Ipsum Blah Blah Blah....</p>
                            </div>
                        </div>
                        <div class="item">
                            <img src="" alt="Chania">
                            <div class="carousel-caption">
                                <h3>Header of Slide 2</h3>
                                <p>Details of Slide 2. Lorem Ipsum Blah Blah Blah....</p>
                            </div>
                        </div>
                        <div class="item">
                            <img src="" alt="Flower">
                            <div class="carousel-caption">
                                <h3>Header of Slide3</h3>
                                <p>Details of Slide 3. Lorem Ipsum Blah Blah Blah....</p>
                            </div>
                        </div>
                 </div>
                        <!-- << Controladores >> -->
                        <a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
                            <span class="fa fa-angle-left" aria-hidden="true"></span>
                            <span class="sr-only">Previous</span>
                        </a>
                        <a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
                            <span class="fa fa-angle-right" aria-hidden="true"></span>
                            <span class="sr-only">Next</span>
                        </a>
                        <!-- Indicadores  0 0 0-->
                        <ol class="carousel-indicators">
                            <li data-target="#myCarousel" data-slide-to="0" class="active"></li>
                            <li data-target="#myCarousel" data-slide-to="1"></li>
                            <li data-target="#myCarousel" data-slide-to="2"></li>
                        </ol>
                    </div>
                <!--FIM CAROUSEL  -->
        </div>
    </div>
</section>
<section>
    <div class="row">
            <div class="col-lg-6">
            <!-- CAROUSEL-->    
                 <div id="myCarousel" class="carousel slide" data-ride="carousel">
                    <div class="carousel-inner" role="listbox">
                         <div class="item active">
                            <img src="" alt="Chania">
                            <div class="carousel-caption">
                                <h3>Lorem ipsum dolor sit amet</h3>
                                <p>Details of Slide 1. Lorem Ipsum Blah Blah Blah....</p>
                            </div>
                        </div>
                        <div class="item">
                            <img src="" alt="Chania">
                            <div class="carousel-caption">
                                <h3>Header of Slide 2</h3>
                                <p>Details of Slide 2. Lorem Ipsum Blah Blah Blah....</p>
                            </div>
                        </div>
                        <div class="item">
                            <img src="" alt="Flower">
                            <div class="carousel-caption">
                                <h3>Header of Slide3</h3>
                                <p>Details of Slide 3. Lorem Ipsum Blah Blah Blah....</p>
                            </div>
                        </div>
                 </div>
                        <!-- << Controladores >> -->
                        <a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
                            <span class="fa fa-angle-left" aria-hidden="true"></span>
                            <span class="sr-only">Previous</span>
                        </a>
                        <a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
                            <span class="fa fa-angle-right" aria-hidden="true"></span>
                            <span class="sr-only">Next</span>
                        </a>
                        <!-- Indicadores  0 0 0-->
                        <ol class="carousel-indicators">
                            <li data-target="#myCarousel" data-slide-to="0" class="active"></li>
                            <li data-target="#myCarousel" data-slide-to="1"></li>
                            <li data-target="#myCarousel" data-slide-to="2"></li>
                        </ol>
                    </div>
                <!--FIM CAROUSEL  -->
        </div>
        <div class="col-lg-6">
            <h3>Titulo nivel 3</h3>
            <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
            tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
            quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
            consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
            cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
            proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
        </div>
    </div>
</section>
<section>
    <div class="row">
        <div class="col-lg-6">
            <h3>Titulo nivel 3</h3>
            <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
            tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
            quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
            consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
            cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
            proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>

        </div>
            <div class="col-lg-6">
            <!-- CAROUSEL-->    
                 <div id="myCarousel" class="carousel slide" data-ride="carousel">
                    <div class="carousel-inner" role="listbox">
                         <div class="item active">
                            <img src="" alt="Chania">
                            <div class="carousel-caption">
                                <h3>Lorem ipsum dolor sit amet</h3>
                                <p>Details of Slide 1. Lorem Ipsum Blah Blah Blah....</p>
                            </div>
                        </div>
                        <div class="item">
                            <img src="" alt="Chania">
                            <div class="carousel-caption">
                                <h3>Header of Slide 2</h3>
                                <p>Details of Slide 2. Lorem Ipsum Blah Blah Blah....</p>
                            </div>
                        </div>
                        <div class="item">
                            <img src="" alt="Flower">
                            <div class="carousel-caption">
                                <h3>Header of Slide3</h3>
                                <p>Details of Slide 3. Lorem Ipsum Blah Blah Blah....</p>
                            </div>
                        </div>
                 </div>
                        <!-- << Controladores >> -->
                        <a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
                            <span class="fa fa-angle-left" aria-hidden="true"></span>
                            <span class="sr-only">Previous</span>
                        </a>
                        <a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
                            <span class="fa fa-angle-right" aria-hidden="true"></span>
                            <span class="sr-only">Next</span>
                        </a>
                        <!-- Indicadores  0 0 0-->
                        <ol class="carousel-indicators">
                            <li data-target="#myCarousel" data-slide-to="0" class="active"></li>
                            <li data-target="#myCarousel" data-slide-to="1"></li>
                            <li data-target="#myCarousel" data-slide-to="2"></li>
                        </ol>
                    </div>
                <!--FIM CAROUSEL  -->
        </div>
    </div>
</section>
<section>
    <div class="row">
            <div class="col-lg-6">
            <!-- CAROUSEL-->    
                 <div id="myCarousel" class="carousel slide" data-ride="carousel">
                    <div class="carousel-inner" role="listbox">
                         <div class="item active">
                            <img src="" alt="Chania">
                            <div class="carousel-caption">
                                <h3>Lorem ipsum dolor sit amet</h3>
                                <p>Details of Slide 1. Lorem Ipsum Blah Blah Blah....</p>
                            </div>
                        </div>
                        <div class="item">
                            <img src="" alt="Chania">
                            <div class="carousel-caption">
                                <h3>Header of Slide 2</h3>
                                <p>Details of Slide 2. Lorem Ipsum Blah Blah Blah....</p>
                            </div>
                        </div>
                        <div class="item">
                            <img src="" alt="Flower">
                            <div class="carousel-caption">
                                <h3>Header of Slide3</h3>
                                <p>Details of Slide 3. Lorem Ipsum Blah Blah Blah....</p>
                            </div>
                        </div>
                 </div>
                        <!-- << Controladores >> -->
                        <a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
                            <span class="fa fa-angle-left" aria-hidden="true"></span>
                            <span class="sr-only">Ant</span>
                        </a>
                        <a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
                            <span class="fa fa-angle-right" aria-hidden="true"></span>
                            <span class="sr-only">Prx</span>
                        </a>
                        <!-- Indicadores  0 0 0-->
                        <ol class="carousel-indicators">
                            <li data-target="#myCarousel" data-slide-to="0" class="active"></li>
                            <li data-target="#myCarousel" data-slide-to="1"></li>
                            <li data-target="#myCarousel" data-slide-to="2"></li>
                        </ol>
                    </div>
                <!--FIM CAROUSEL  -->
        </div>
        <div class="col-lg-6">
            <h3>Titulo nivel 3</h3>
            <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
            tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
            quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
            consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
            cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
            proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
        </div>
    </div>
</section>
  • Please post your javascript code (jQuery) that makes the change in the Carousel so we can analyze. Probably the modification is being made by ID or by the first element with the class "Carousel".

  • The problem is probably in id that you’re using. From what I saw on Exp html that is using, all elements have the same id, id is a unique attribute that the DOM sees, when he references him by jquery or javascript, he takes only the first element he finds

  • I managed to solve it myself.. My lack of attention.. really was the ID ! thanks anyway!

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.