I am having issues with my scripts conflicting.. Please help

Discussion in 'jQuery' started by secretsau, Nov 19, 2011.

  1. #1
    Hi everyone,

    I am having the following problems using multiple scripts on one page of my HTML. Only the lightbox script works, however the accordion doesn't work :(

    Here is my code:

    <script type="text/javascript" src="scripts/jquery-1.5.1.min.js"></script>
            <script src="scripts/prototype.js" type="text/javascript"></script>
            <script src="scripts/scriptaculous.js" type="text/javascript"></script>
            <script src="scripts/lightbox.js" type="text/javascript"></script>
             <script src="scripts/effects.js" type="text/javascript"></script>
                   
    <script type="text/javascript">
    $(document).ready(function(){
       
        $(".accordion h3").eq(2).addClass("active");
        $(".accordion p").eq(2).show();
       
        $(".accordion h3").click(function(){
        $(this).next("p").slideToggle("slow")
        .siblings("p:visible").slideUp("slow");
        $(this).toggleClass("active");
        $(this).siblings("h3").removeClass("active");
        });
    }); 
    Code (markup):
    Any ideas on how this may work?? Thanks
     
    secretsau, Nov 19, 2011 IP
  2. xrvel

    xrvel Notable Member

    Messages:
    918
    Likes Received:
    30
    Best Answers:
    2
    Trophy Points:
    225
    #2
    Try to use FireFox to detect any JS error. :)
    That usually helps.
     
    xrvel, Nov 22, 2011 IP
  3. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #3
    In case one of the other libraries uses $, try
    <script type="text/javascript" src="scripts/jquery-1.5.1.min.js"></script>
            <script src="scripts/prototype.js" type="text/javascript"></script>
            <script src="scripts/scriptaculous.js" type="text/javascript"></script>
            <script src="scripts/lightbox.js" type="text/javascript"></script>
             <script src="scripts/effects.js" type="text/javascript"></script>
                   
    <script type="text/javascript">
    jQuery(document).ready(function(){
       
        jQuery(".accordion h3").eq(2).addClass("active");
        jQuery(".accordion p").eq(2).show();
       
        jQuery(".accordion h3").click(function(){
        jQuery(this).next("p").slideToggle("slow").siblings("p:visible").slideUp("slow");
        jQuery(this).toggleClass("active");
        jQuery(this).siblings("h3").removeClass("active");
        });
    }); 
    Code (markup):
    Or see the jQuery site for help with $.noConflict().
     
    Rukbat, Dec 1, 2011 IP
  4. lamvt

    lamvt Active Member

    Messages:
    153
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    58
    #4
    I agree with Rukbat Use jQuery replace for $ or use noConflict functions will help you to solve it.
    and check your

    effects.js too
     
    lamvt, Dec 7, 2011 IP