I'm setting up the function to open a menu. But I'm getting the error message "Uncaught TypeError: Can not read property 'addEventListener' of null"
Below is the code I'm using to open the menu with JS
var veri = 1;
var trigger = document.getElementById('menu-trigger').addEventListener("click",function(){
var menu = document.getElementById('menu-hidde');
if (veri == 1) {
menu.style.left = "0px";
veri = 0;
}else{
menu.style.left = "-100%";
veri = 1;
}
})
And also the HTML code where I quote the same
<!DOCTYPE html>
<html lang"en">
<head>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="estilos.css" media="all" />
<script type="text/javascript" src="teste.js"></script>
<script defer src="https://use.fontawesome.com/releases/v5.0.9/js/all.js"integrity="sha384-8iPTk2s/jMVj81dnzb/iFR2sdA7u06vHJyyLlAd4snFpCl/SnyUjRrbdJsw1pGIl" crossorigin="anonymous"></script>
<title>Styles Conference</title>
</head>
<body>
<div class="menu-trigger" id="menu-trigger">
<div></div>
<div></div>
<div></div>
</div>
<nav class="menu-hidde" id="menu-hidde">
<ul>
<li>teste</li>
<li>teste</li>
<li>teste</li>
<li>teste</li>
</ul>
</nav>
How can I fix this?