i wrote this piece of code that only works when i have the script tag in the html file after the end of the body tag. however when i cut and paste the js code in an external file named start.js, and reference it in the html inside the head tag, it doesnt work.
i tried this:
<!DOCTYPE html>
<html>
<head>
<title>Start</title>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="start.css">
<meta name="viewport" content="width=device-width, initial-
scale=1.0">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-
awesome/4.7.0/css/font-awesome.min.css">
<script src="start.js"></script>
</head>
and this:
<!DOCTYPE html>
<html>
<head>
<title>Start</title>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="start.css">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-
awesome/4.7.0/css/font-awesome.min.css">
<script type="text/javascript" src="start.js"></script>
</head>