Skip to content Skip to sidebar Skip to footer

Javascript File Not Working When Linked From HTML

so I feel(and hope) this is pretty simple. I am new to javascript and am trying to get this working. When I link to my external .js file from my html it does not function. However,

Solution 1:

You are using jQuery, but it doesn't seem like you have included it. Add this to your HEAD element

<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>

Solution 2:

You need to import jQuery.

<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>

Solution 3:

Actually, i had a problem like this and i tried the code below.

<head>
<meta charset="ISO-8859-1">
<title></title>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
</head>

Solution 4:

You dont have jquery in your <head> section. Add it before you add scripts.js. Only then will your code work.

<head>
  <title>slidepanel test</title>
  <link rel="stylesheet" type="text/css" href="style.css"/>

  <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
  <script type="text/javascript" src="script.js"></script>

</head>

If you're testing this in your local machine, add a http to the src or download your own copy of jQuery.

And just as a sidenote, its always better to add stylesheets before your js files.


Solution 5:

Looks like you're missing jQuery. Include it before you include your own JavaScript code.


Post a Comment for "Javascript File Not Working When Linked From HTML"