Not even really sure what kind of title this question needs. Basically I have made a cheeky bit of JavaScript in jsFiddle and it works perfectly. Then I've popped on a test site and it doesn't work at all. I cannot figure out why at all and it's doing my head in.
Basically the code calculates the width of the image and uses this value to place the image in the center of the page. Works great on the window.resize but for some reason the document.load isn't working on the test server but it works fine in JS Lint. I've popped an alert in there as well for testing purposes.
jsFiddle Link: http://jsfiddle.net/sambeckhamdesign/4g4nD/49/
Load jQuery before your script and use your browser's error console
Uncaught ReferenceError: $ is not defined java.js:9
You've put your javascript method above the call to include jQuery.
At that point, jQuery hasn't been defined. Switch the lines so that jQuery is first.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js" type="text/javascript"></script>
<script src="/_js/java.js" type="text/javascript"></script>
you have
<script src="/_js/java.js" type="text/javascript"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js" type="text/javascript"></script>
it should be
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js" type="text/javascript"></script>
<script src="/_js/java.js" type="text/javascript"></script>
精彩评论