Skip to content
Advertisement

HTML link to external javascript not working

I am new to JavaScript. I created an external script for my webpage but it’s not working. But when I write it inside the html it works fine. Here is my script.

JavaScript

Here is my HTML

JavaScript

Advertisement

Answer

  1. Check Chrome Developer to see if the js file is being included
  2. Is the path correct? Should it be ‘/indexahnew.js’?
  3. Remove the new line in the script tag
  4. Add the script tag to the end of your html body instead of the head (best practice)
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement