I would like to know why when I make a console.log
in my main.js, it returns null in the console, although, when I declare <script>main.js</script>
inside the body, it returns the value of the id I'm looking for. Follow the script example inside the head.
(function(win, doc){
'use strict';
console.log(document.getElementById('text-link'));
})(window, document);
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<script src="main.js"></script>
</head>
<body>
<a id="test-link" >text</a>
</body>
</html>