I’ve got the html and i’ve linked to a script
<!DOCTYPE html>
<html lang="en">
<head>
<script type="text/javascript" src="script.js"></script>
<title>Hello</title>
</head>
<body>
<h1>This is some header</h1>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
In id odio sapien, vitae consectetur ante. Ut eget nisl magna.
Aliquam risus enim, mollis sed venenatis quis, feugiat a augue.
Aliquam et <a href="#" id="berenger">libero</a> quam, nec sollicitudin ipsum.
</p>
</body>
</html>
Here’s script.js
var target = document.getElementById('berenger');
alert(target.nodeName);
Why isn’t the alert box appearing when i load the page?
I’m trying out the example in chapter 3 where we learn to access the element node using the id by using getElementById method.