-2

Hi as new Developer I've never actually created a JS file from "scratch" before and when I try to write something basic to see if my jQuery works dev tools just tells me "reference error". I thought at the end of a js doc i just added like }); (jQuery, window) or something along those lines but nothing I've tried has worked.

html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="en">
<script type="text/javascript" src="default.js"></script>
<script src="jquery-1.11.3.min.js"></script>
<head>
    <link rel="stylesheet" href="default.css" type="text/css" />
    <title></title>
</head>
<body>
    <div class="container">
    <div class="column"><a href="https://www.google.co.uk"> Solution Assessment</a></div>
    <div class="column"><a href="https://www.google.co.uk"> Design</a></div>
    <div class="column"><a href="https://www.google.co.uk"> Build</a></div>
    <div class="column"><a href="https://www.google.co.uk"> Deploy</a></div>
    <div class="column"><a href="https://www.google.co.uk"> Test</a></div>
    <div class="column"><a href="https://www.google.co.uk"> Live (BAU)</a></div>

</div>
</body>
</html>

basic js

// JavaScript source code
$( document ).ready(function() {

    // Your code here.

});

I'm assuming I need to reference in the js page as well but I've no clue what the correct syntax is... Sorry for the 'newbie' question I've been looking for an hour or so and not been able to google properly.

James Thorpe
  • 31,411
  • 5
  • 72
  • 93
Davington III
  • 107
  • 12
  • If default.js has your code in it, the call to it must come _after_ you call jQuery. Also, those ` – Andy Aug 14 '15 at 15:47

1 Answers1

6

First you run your script which tries to use jQuery:

<script type="text/javascript" src="default.js"></script>

Then you load jQuery:

<script src="jquery-1.11.3.min.js"></script>

You can't use jQuery before you load it. Swap the order of your scripts.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335