I added JQuery to my HTML file:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
Then I add a link to my JavaScript file:
<script src="public/javascripts/new_javascript.js" type="text/javascript"></script>
(I checked that this link work.)
In the file I do
$(document).ready(function() {
alert("hey!");
});
But the Google Chrome developer tool shows an error:
Uncaught TypeError: Object #<HTMLDocument> has no method 'ready'
How can it be an error?
I'm doing this in Rails, and the HTML is like:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script src="public/javascripts/prototype.js?1349898477" type="text/javascript"></script>
<script src="public/javascripts/effects.js?1349898477" type="text/javascript"></script>
<script src="public/javascripts/dragdrop.js?1349898477" type="text/javascript"></script>
<script src="public/javascripts/controls.js?1349898477" type="text/javascript"></script>
<script src="public/javascripts/rails.js?1349898477" type="text/javascript"></script>
<script src="public/javascripts/application.js?1349898477" type="text/javascript"></script>
<script src="public/javascripts/new_javascript.js?1351137775" type="text/javascript"></script>
$function used by jQuery. Why do you have them both?jQueryinstead of$(because Prototype has overwritten$).