HTML file not communicating with JavaScript File (traditional event handler issue?)

Hey all,

I’ve created various projects on websites like codeacademy and codepen and decided to transfer my code into an external text editor (Notepad++).

When I run the HTML files in my browser, the CSS files works fine but the JavaScript files do not work (unless I use inline event handlers). I’ve linked the files in the HTML document, made sure they all sit in the same folder, and have run through the code for an possible syntax mistakes.

<!DOCTYPE html>
<html>
<head>
	<link rel="stylesheet" href="test.css"/>
	<script src="test.js"></script>
</head>

I feel as though I am missing something simple within the JS file because whenever I use inline event handlers, the JavaScript files run fine. When I use traditional event handlers, the file does not work at all.

Any ideas about what I might be doing wrong?

Thanks

You are attaching the JavaScript in the wrong place.

<!DOCTYPE html>
<html>
<head>
	<link rel="stylesheet" href="test.css"/>
</head>
<body>

<script src="test.js"></script></body>
</html>

Oh wow, thank you very much! I had a feeling it was something as trivial as that.

As you are writing js link in head section, it is not loading properly. It is always good practice to keep js files at bottom before we close </body> ,It would be called as defer parsing of javascript. For more details pls check with URL
: http://gtmetrix.com/defer-parsing-of-javascript.html