lundi 19 décembre 2016

Getting document is not defined , from document.getElementById

I am learning JavaScript and I am using Atom (Text Editor). On my HTML file I got only this:

<!DOCTYPE html>
<html>
<head>
    <link rel="stylesheet" href="style.css">
    <script src="script.js"></script>
</head>
<body>
    <h1>Hello Plunker!</h1>
    <button id="displayTodosButton">Display Todos</button>
    <button>Toggle Todos</button>
</body>
</html>

On my javascript file, I am simply trying to access the "Display todos" button using this:

var displayTodosButton = document.getElementById('displayTodosButton')

I was watching a video, and the instructor is using plnkr.co, and he accesses the button just fine, yet on Atom I get the "ReferenceError: document is not defined"

How can I fix this?




Aucun commentaire:

Enregistrer un commentaire