Basic jQuery not working

Hi,

I am attempting to learn jQuery and following the examples in the book titled ‘jQuery: Novice to Ninja’.

One of the first pieces of code I am trying to do is show a simple ‘Alert’.

I am running this on a local setup and only using a basic html page at the moment.

I am using an external js file and have checked that the paths work.

Here is my code within the head of the document [also tried when in the footer].

  <script type="text/javascript" src="/js/jquery-1.11.1.js"></script>
    <script type="text/javascript" src="/js/example.js"></script>

Checked and double checked that all names and paths are correct.

The simple piece of jQuery I am trying to run is as follows…

 <script>
$(document).ready(function() {
  alert('Alert, alert, the world needs more Lerts!');
});
</script>

I have also tried using…

 <script>
$(function() {
  alert('Alert, alert, the world needs more Lerts!');
});
</script>

If anyone can see what I am am doing wrong, could you please let me know.

I have not even started and I am failing! Woe, what is to become of me!

Thank you

James

Your example.js doesn’t need the <script> tags in it. You only need to put the <script> tags when you are adding JavaScript into a HTML file directly rather than from an external file.

Thank you Patche.

Slapping myself now.

I knew this was how it was done. Sheesh!

Maybe I am not cut out for jQuery :frowning:

Haha nah we all start somewhere :smiley: