Reputation: 13672
I am including JQuery in my site and referencing to external scripts that will utilize the Jquery afterwards. However, I don't think they are running as Jquery, they are just failing... My HTML looks like this:
<script type="text/javascript" src="lib/jquery/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="lib/load.js"></script>
<script type="text/javascript" src="lib/logErr.js"></script>
In the head section. load.js contains this: $('body').css('background-color','black'); but does not work. When I switched it to state: alert('Hey'); using simple Javascript, it did work. All files do work. Please any suggestions?
Upvotes: 0
Views: 102
Reputation: 2618
Without further information it is hard to say what problem you are having.
When you are using Firefox try to use Firebug with its integrated console. The console will give you more details about whether JQuery was successfully loaded or errors in your code.
In Chrome you can use the Developer Tools with integrated console.
Instead of using alert for logging the state of your script use the console instead:
console.log('Hey'); // Will print 'Hey' in the console.
console.log(some_variable); // Will print variable content and information.
With a concrete console error message and your code it would be easier to help you.
In addition you can use both tools mentioned above to track your network and see if the scripts are loaded properly or not. So you will get to know whether JQuery was loaded or not.
Upvotes: 0
Reputation: 1926
Did you try wrapping it in the load event?
$(function() {
$('body').css('background-color','black');
});
Upvotes: 1
Reputation: 55740
1st option Just have an alert in DOM ready Event
$(function() {
alert('jQuery Loaded !!');
});
2nd Option is to hit the F12 in the browser and check for the jQuery file in the scripts section. If jQuery is loaded properly then you can see the script file in there..
EDIT Looks to me like a file reference error.. Why not use jQuery hosted by Google CDN
Include this in your header section instead of the jQuery file you are using
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
Upvotes: 2