سؤال

I have used easy slider for my slideshow. I need to use the same slider in two places in the same html page.

I have tried this but only one slider is working.

<script type="text/javascript" src="js/easySlider.packed.js"></script>
<script type="text/javascript">
    $(document).ready(function(){   
        $("#slider_single").easySlider();
        $("#slider_specials").easySlider(); 


});
</script>

Html code:

<div id="slider_single">
<ul>
<li><a href="#"><img src="images/slider1.jpg" alt="" /></a></li>
<li><a href="#"><img src="images/slider2.jpg" alt="" /></a></li>
</ul>
</div>


<div id="slider_specials">
<ul>
<li><a href="#"><img src="images/slider3.jpg" alt="" /></a></li>
<li><a href="#"><img src="images/slider4.jpg" alt="" /></a></li>
</ul>
</div>

How to fix this?

هل كانت مفيدة؟

المحلول

@lifeline Please refer this link for Easy Slider making Two Slider in Same HTML Page

(or) change your Script like this

<script type="text/javascript">
        $(document).ready(function(){   
            $("#slider_single").easySlider({
                auto: true,
                continuous: true

            });
            $("#slider_specials").easySlider({ 
                auto: true,
                continuous: true
            });
        }); 
    </script>

نصائح أخرى

I have no issues with making two easy sliders at a single document.

checkout the fiddle: http://jsfiddle.net/Qetmn/

html used:

<div class='content' id="slider_single">
<ul>
    <li><a href="http://templatica.com/preview/30"><img src="images/01.jpg" alt="Css Template Preview" /></a></li>
    <li><a href="http://templatica.com/preview/7"><img src="images/02.jpg" alt="Css Template Preview" /></a></li>
    <li><a href="http://templatica.com/preview/25"><img src="images/03.jpg" alt="Css Template Preview" /></a></li>
    <li><a href="http://templatica.com/preview/26"><img src="images/04.jpg" alt="Css Template Preview" /></a></li>
    <li><a href="http://templatica.com/preview/27"><img src="images/05.jpg" alt="Css Template Preview" /></a></li>
</ul>
</div>
<div class='content' id="slider_specials">
<ul>
    <li><a href="http://templatica.com/preview/30"><img src="images/01.jpg" alt="Css Template Preview" /></a></li>
    <li><a href="http://templatica.com/preview/7"><img src="images/02.jpg" alt="Css Template Preview" /></a></li>
    <li><a href="http://templatica.com/preview/25"><img src="images/03.jpg" alt="Css Template Preview" /></a></li>
    <li><a href="http://templatica.com/preview/26"><img src="images/04.jpg" alt="Css Template Preview" /></a></li>
    <li><a href="http://templatica.com/preview/27"><img src="images/05.jpg" alt="Css Template Preview" /></a></li>
</ul>
</div>

css used:

 .content {
    position:relative;
 }
 .content img {
    width:696px;
    height:241px;
 }
 .content ul, .content ul li {
    margin:0;
    padding:0;
    list-style:none;
 }

and your same jQuery:

$("#slider_specials").easySlider();
$("#slider_single").easySlider();

and this easy slider plugin:

http://cssglobe.com/lab/easyslider1.7/js/easySlider1.7.js

On the divs you need to be sure your CSS styles are applied. Here is a style that I know works with two sliders on the same page.

<div id="slider" style="width: 696px; height: 241px; overflow: hidden;">
  <ul style="width: 4176px; margin-left: -2088px;">
    <li style="float: left; margin-left: -696px;">
    <li style="float: left;" />
    <li style="float: left;" />
    <li style="float: left;" />
  </ul>
</div>

Try that on both of your sliders and see if that makes it so they both work on the same page.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top