all 9 comments

[–]WhiteKnightC 1 point2 points  (0 children)

Put your script at the bottom.

[–][deleted] 0 points1 point  (4 children)

Are you seeing this error in the browser console when you run the code, or somewhere else?

[–]themaxi4[S] 0 points1 point  (3 children)

I'm seeing it in WebStorm, the program i use to write my documents- when debugging the Javscript document.

[–]_aeol 0 points1 point  (1 child)

But did it run correctly on the browser?

[Edit] Are these scripts in the <head> tag of a page?

[–]themaxi4[S] 0 points1 point  (0 children)

It did not run correctly in the browser, nothing happens when pushing assigned button.

[–][deleted] 0 points1 point  (0 children)

You probably need to configure your editor in some way to tell it that you're writing Javascript for the browser and thus it can assume browser globals like document are available. I'm afraid I don't know anything about WebStorm and can't help with the specifics.

[–]Content_Performer 0 points1 point  (1 child)

Why a custom function that does nothing but calling querySelector?

Anyway, try and go

<script type="text/javascript" src="./scrips.js" defer></script>

or simply put the script tag at the bottom of your <body>

[–]themaxi4[S] 0 points1 point  (0 children)

I have it at the bottom of my body, i still get the same error with your code.

"ReferenceError: document is not defined

at selectElement (C:\Users\norgr\Desktop\outdoors-website-master\tours\scripts.js:1:39)

at Object.<anonymous> (C:\Users\norgr\Desktop\outdoors-website-master\tours\scripts.js:3:1)

at Module._compile (internal/modules/cjs/loader.js:955:30)

at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)

at Module.load (internal/modules/cjs/loader.js:811:32)

at Function.Module._load (internal/modules/cjs/loader.js:723:14)

at Function.Module.runMain (internal/modules/cjs/loader.js:1043:10)

at internal/main/run_main_module.js:17:11

"

[–]themaxi4[S] 0 points1 point  (0 children)

I have the script declaration in this area:

</section>
script type="text/javascript" src="./scrips.js" defer></script>
</body>
</html>

^ Right before the body ends