Search code examples
javascriptjqueryeasyslider

$("#slider").easySlider is not a function


I'm not used to work with jQuery, but I thought to use the easyslider for showing some pictures on my website. The problem is that I get this error: $("#slider").easySlider is not a function I don't know what I have done wrong, because if I open the page alone, there is no problem, but when I place the file back between others it won't work. Here's my code :

    <script type="text/javascript" src="/js/jquery.js"></script>
    <script type="text/javascript" src="/js/easySlider1.7.js"></script>
    <script type="text/javascript">
        $(document).ready(function(){   
            $("#slider").easySlider({
                auto: true, 
                continuous: true
            });
        }); 
    </script>

<div class="block">
    <div class="m950 flb">  

<div id="slider" style="position:relative; width:947px; height:615px; left:-20px;  top:-3px; overflow:hidden;">
<ul>                
                <li><img src="/images/slideshow/1.jpg" /></li>
        <li><img src="/images/slideshow/2.jpg" /></li>
        <li><img src="/images/slideshow/3.jpg" /></li>
        <li><img src="/images/slideshow/4.jpg" /></li>
        <li><img src="/images/slideshow/5.jpg" /></li>
                <li><img src="/images/slideshow/6.jpg" /></li>
        <li><img src="/images/slideshow/7.jpg" /></li>
        <li><img src="/images/slideshow/8.jpg" /></li>
        <li><img src="/images/slideshow/9.jpg" /></li>
        <li><img src="/images/slideshow/10.jpg" /></li>

</ul>
</div>



</div>
</div>

Does someone know what I could do to make it work, because I've been braking my head for this problem.

Thank you so much in advance!


Solution

  • Try this:

     <script type="text/javascript">
    ( function($) {
        // we can now rely on $ within the safety of our “bodyguard” function
        $(document).ready( function() { 
                $("#slider").easySlider({
                    auto: true, 
                    continuous: true
                });
                  } );
    } ) ( jQuery );
    
    </script>
    

    It's a way around it.