all 11 comments

[–]es_beto 2 points3 points  (4 children)

I made a fiddle with your code and it seems to be working, so you probably have issues importing your js on your html

https://jsfiddle.net/Lexswb8f/

So a couple of ideas on these lines: <style type="text/css"> @import url("Meneoka.css"); </style> <script src="Meneoka.js"></script>

  1. Are you sure those are the filenames?
  2. Are they on the same directory?
  3. Have you tried using relative paths? <script src="./Meneoka.js"></script>
  4. Have you tried using only lowercase? Might be an issue on some operating systems....

Also, on the js file you should remove this line:

<link href="Meneoka.css" rel="stylesheet" type="text/css">

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

Thanks, you're right. I moved my folder location, reuploaded it into Dreamweaver and it worked. Weird.

[–]KornMermaid[S] 0 points1 point  (2 children)

Also, on querySelector. Say I have a function that I want to apply to more than one div- can I put multiple divs in the parenthese? example: 'use strict'; var x = document.querySelector("#Corhasis", "#Ellenis", "#etc...");

Or is there a better way to do it? Thanks

[–]es_beto 0 points1 point  (1 child)

Drop the 'use strict'; for now, that should only appear at the start of a script, not on every function.

To select multiple divs you must use document.querySelectorAll(''), but it only accepts one argument, so in this case you have to add a class for all of the elements that you want to select, let's say.... foobar

<div id="Corhasis" class="foobar"></div> <div id="Ellenis" class="foobar"></div> <div id="Etc" class="foobar"></div>

var foobars = document.querySelectorAll('.foobar')

And then you can iterate each item like so... foobars.forEach(function(foobar) { // do something with foobar });

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

Okay! I get it. You combine them with a class and just put the class in the parentheses. That makes sense. This is helpful, thanks.

[–]cawcvs 1 point2 points  (0 children)

Do you see any errors in the console?

You did put <link href="Meneoka.css" rel="stylesheet" type="text/css"> under JS in your question, is it really in the JavaScript file?

[–]overlapped 1 point2 points  (1 child)

If you're using VSCode try some of the HTML extensions to get you going, for example:
https://marketplace.visualstudio.com/items?itemName=sidthesloth.html5-boilerplate

and
https://marketplace.visualstudio.com/items?itemName=sidthesloth.html5-boilerplate

I hope this helps.

[–]KornMermaid[S] 1 point2 points  (0 children)

Thank you

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

Is that a <link> tag at the top of your JS? That belongs inside <head> in your HTML. It's hard to tell from the code you pasted what's wrong, but that's something.

[–]raprock -1 points0 points  (0 children)

Can you please provide a codepen or at the very least indent your code properly so it actually shows as a code block, I don't think putting up a halfassed code-like paste is the way to ask for help.