-1

I have slide show of images which was prepared by using jquery.jcarousel.min.js.
Now in same page I want to replicate same slide show.

below is my code:

<div class="connected-carousels">
            <div class="stage">
                <div class="carousel carousel-stage" data-jcarousel="true">
                 <ul style="left: 0px; top: 0px;">
                         <li><img src="http://localhost/classapp/Images/Jsc/img/img1.jpg" width="600" height="400" alt=""></li>
                 <li><img src="http://localhost/classapp/Images/Jsc/img/img2.jpg" width="600" height="400" alt=""></li>
                 <li><img src="http://localhost/classapp/Images/Jsc/img/img3.jpg" width="600" height="400" alt=""></li>
                 <li><img src="http://localhost/classapp/Images/Jsc/img/img4.jpg" width="600" height="400" alt=""></li>
                 <li><img src="http://localhost/classapp/Images/Jsc/img/img5.jpg" width="600" height="400" alt=""></li>
                 <li><img src="http://localhost/classapp/Images/Jsc/img/img6.jpg" width="600" height="400" alt=""></li>
                 </ul>
                </div>
                <p class="photo-credits">
                    Photos by <a href="http://www.mw-fotografie.de">Marc Wiegelmann</a>
                </p>
                <a href="#" class="prev prev-stage inactive" data-jcarouselcontrol="true"><span>‹</span></a>
                <a href="#" class="next next-stage" data-jcarouselcontrol="true"><span>›</span></a>
            </div>

            <div class="navigation">
                <a href="#" class="prev prev-navigation inactive" data-jcarouselcontrol="true">‹</a>
                <a href="#" class="next next-navigation" data-jcarouselcontrol="true">›</a>
                <div class="carousel carousel-navigation" data-jcarousel="true">
                    <ul style="left: 0px; top: 0px;">
                   <li data-jcarouselcontrol="true" class="active">
<img src="http://localhost/classapp/Images/Jsc/img/img1_thumb.jpg" width="50" height="50" alt=""></li>
                 <li data-jcarouselcontrol="true">
<img src="http://localhost/classapp/Images/Jsc/img/img2_thumb.jpg" width="50" height="50" alt=""></li>
                 <li data-jcarouselcontrol="true">
<img src="http://localhost/classapp/Images/Jsc/img/img3_thumb.jpg" width="50" height="50" alt=""></li>
                 <li data-jcarouselcontrol="true">
<img src="http://localhost/classapp/Images/Jsc/img/img4_thumb.jpg" width="50" height="50" alt=""></li>
                 <li data-jcarouselcontrol="true">
<img src="http://localhost/classapp/Images/Jsc/img/img5_thumb.jpg" width="50" height="50" alt=""></li>
                 <li data-jcarouselcontrol="true">
<img src="http://localhost/classapp/Images/Jsc/img/img6_thumb.jpg" width="50" height="50" alt=""></li>

        </ul>
    </div>
  </div>
</div>

my javascript code

js used jquery.jcarousel.min.js

<script language="javascript">
 var connector = function(itemNavigation, carouselStage) {
    return carouselStage.jcarousel('items').eq(itemNavigation.index());
};

 function ShowJsSlideShow()
 {
     // Setup the carousels. Adjust the options for both carousels here.
     var carouselStage      = $('.carousel-stage').jcarousel();
     var carouselNavigation = $('.carousel-navigation').jcarousel();

     // We loop through the items of the navigation carousel and set it up
     // as a control for an item from the stage carousel.
     carouselNavigation.jcarousel('items').each(function() {
         var item = $(this);

         // This is where we actually connect to items.
         var target = connector(item, carouselStage);

         item
             .on('jcarouselcontrol:active', function() {
                 carouselNavigation.jcarousel('scrollIntoView', this);
                 item.addClass('active');
             })
             .on('jcarouselcontrol:inactive', function() {
                 item.removeClass('active');
             })
             .jcarouselControl({
                 target: target,
                 carousel: carouselStage
             });
     });

     // Setup controls for the stage carousel
     $('.prev-stage')
         .on('jcarouselcontrol:inactive', function() {
             $(this).addClass('inactive');
         })
         .on('jcarouselcontrol:active', function() {
             $(this).removeClass('inactive');
         })
         .jcarouselControl({
             target: '-=1'
         });

     $('.next-stage')
         .on('jcarouselcontrol:inactive', function() {
             $(this).addClass('inactive');
         })
         .on('jcarouselcontrol:active', function() {
             $(this).removeClass('inactive');
         })
         .jcarouselControl({
             target: '+=1'
         });

     // Setup controls for the navigation carousel
     $('.prev-navigation')
         .on('jcarouselcontrol:inactive', function() {
             $(this).addClass('inactive');
         })
         .on('jcarouselcontrol:active', function() {
             $(this).removeClass('inactive');
         })
         .jcarouselControl({
             target: '-=1'
         });

     $('.next-navigation')
         .on('jcarouselcontrol:inactive', function() {
             $(this).addClass('inactive');
         })
         .on('jcarouselcontrol:active', function() {
             $(this).removeClass('inactive');
         })
         .jcarouselControl({
             target: '+=1'
         });
 }
 $(document).ready(function () {
     ShowJsSlideShow();
 });
    </script>

Is is possible to have same slider on the same webpage using jQuery only without going to code on server side?

skiskd
  • 423
  • 2
  • 9
  • 20

1 Answers1

0

You can try it . you have to correct the image location and edit it however like you . may this will help you . please in your header connect Bootstrap CDN . i think that's enough .

<p> 1st carousel </p>
<div class="1st_carousel_slider">
    <div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
        <!-- 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" role="listbox">
            <div class="item active">
                <img src="..." alt="...">
                <div class="carousel-caption">
                    ...
                </div>
            </div>
            <div class="item">
                <img src="..." alt="...">
                <div class="carousel-caption">
                    ...
                </div>
            </div>
            ...
        </div>

        <!-- Controls -->
        <a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">
            <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
            <span class="sr-only">Previous</span>
        </a>
        <a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next">
            <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
            <span class="sr-only">Next</span>
        </a>
    </div>
</div>
<p> 2nd carousel </p>
<div class="2st_carousel_slider">
    <div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
        <!-- 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" role="listbox">
            <div class="item active">
                <img src="..." alt="...">
                <div class="carousel-caption">
                    ...
                </div>
            </div>
            <div class="item">
                <img src="..." alt="...">
                <div class="carousel-caption">
                    ...
                </div>
            </div>
            ...
        </div>

        <!-- Controls -->
        <a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">
            <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
            <span class="sr-only">Previous</span>
        </a>
        <a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next">
            <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
            <span class="sr-only">Next</span>
        </a>
    </div>
</div>

and please before closing your body tag give siider intervals :

$('.carousel').carousel({ interval: 1000 })