Malmoc
Malmoc

Reputation: 109

Cannot get jQuery to work on site

Okay, I have been working for quite some time on a website for a friend.. My coding skills are .. questionable, and I've been having quite a few problems.

Currently the jQuery on my site simply stopped working, I could not find the reason, and I have done everything I could to try to get it to work. ( I have followed countless guides all over the internet, for troubleshooting etc. and I still cannot get it to work)

-EDIT- I have moved all the files to the top of the code.. Yet the problem persists.

Sincerely yours, Malmoc

Upvotes: 2

Views: 123

Answers (4)

Kristian
Kristian

Reputation: 21810

Looks like you're mixing mootools and jquery. Please resolve your conflict between jquery's $ namespace and mootools' $ namespace.

google "jquery no conflict"

Upvotes: 0

nickaknudson
nickaknudson

Reputation: 4807

Your $ is also getting overwritten by another script. Best that you use jQuery.noConflict() for this

And then you can put your code in a closure like this:

(function(){

    var $ = jQuery;

    // jQuery code using $

})(this);

Upvotes: 0

charlietfl
charlietfl

Reputation: 171679

You are trying to use jQuery code before jQuery.js is loaded.

jQuery.js must load before any dependent code or plugins. Use a browser console and look at errors thrown on page load. "$" is not defined error is a quick indication of loading problem with jQuery

Think of it this way. jQuery library contains a number of functions, including defining "$". If these functions or "$" aren't already available when you call them, they are undefined and errors get thrown and your code won't work

Once you have jQuery script tag before other code, you may still run into complications if you recently added prototype library which also uses "$" alias. This can cause conflicts but there is a workaround using jQuery.noConflict()

Upvotes: 2

NardCake
NardCake

Reputation: 130

Very odd, I suggest you set the source to jQuery to the website here: http://code.jquery.com/jquery-1.8.2.min.js Seems to be quicker response time, and in your source code you appear to link jQuery twice, that may be causing some issues.

Upvotes: 0

Related Questions