Treehouse: Grow your CSS skills. Land your dream job.

Possible to use several Javascript codes on one page?

  • # February 16, 2011 at 11:53 am

    I´m very new to Javascript- is it possible to have multiple functions on one page. For example, an image rotator with one type of script, and a dynamic navigation section?

    The two elements I want to combine are these:

    and a simple image rotator:

    I´ve tried to put them on the same page, but one overrides the other.

    Probably really simple, but I´m very new to Jquery.


    # February 16, 2011 at 12:05 pm

    You can have as many functions on a page as you want. Make sure there are no conflicting variables or functions. Can you provide the exact code so I can tell you what is wrong with it and how to correct?

    # February 16, 2011 at 3:50 pm

    This is the page of Javascript. The slider is at the top, and the Kwicks changer at the bottom.

    Sure it´s something really simple. But when I put these two together, the image slider stops working- some sort of conflict. As I say, I´ve just started using Javascript.

    Many thanks.

    # February 16, 2011 at 5:12 pm

    Your top script tag has no type attribute.

    Put them both in the same script tag at the bottom of the page if you please. It also looks like you have a link to the jquery library twice in there, if that’s the same page.

    # February 16, 2011 at 6:28 pm

    Also, try to use the most current jQuery version.

    jQuery-1.2.6 is quite old. It could be causing some problems as well.

    # February 17, 2011 at 5:10 am

    Thanks for that guys. Really helpful.

    School boy errors as I thought!!

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.