Document Object Model #3 - Javascript and the DOM


#1

this is saved in main.js
My code says:

var skillset =
document.getElementsByClassName('skillset');

error: Does skillset equal a document.getElementsByClassName function?

What am I doing wrong?


#2

This belongs in JavaScript...

Make sure you make your document ready first.


#3

We can only give you a decent answer if we know what exercise this is. Please post a link to the exercise so we can read the instructions and test your code. Thanks.


#4

Oops, here is the link:

https://www.codecademy.com/en/courses/learn-javascript/lessons/javascript-dom/exercises/jquery-selectors


#5

Do you mean 2.3 or lesson 3?


#6

Sorry, It's from the 5th lesson, exercise 3.
Thank you so much for your patience! I really appreciate your help!


#7

This lesson moves away from vanilla JS and uses jQuery. Take a close look at the lesson text and the examples. The rest is pretty much spelled out for us. Just follow the steps, and use a jQuery selector, not document.getElement...


#8

Thank you so much! I still haven't figured anything out yet. The instructions don't say anything about jquery. There was a "hint" below the instructions saying to use
document.getElementsByClassName('skillset');
That's also what was used in the example as well. I guess I will start over from the beginning. I have noticed a couple times when the answer I needed was not necessarily explained in the instructions or examples, so I think it's entirely possible that the answer is a jquery selector despite that not being in the instructions.


#9

The title of the lesson is, jQuery Selectors, and the example given shows how a selector would compare to the equivalent vanilla JS selector. Not only that, the setup we begin with is jQuery:

function main() {

}

$document.ready(main); // jQuery

The last line waits for the DOM Content to load then runs the main() function.


#10

I'm sorry that does not look familiar. Perhaps I shared an incorrect link, otherwise I'm very lost now. I've attached a screenshot.
I'm sorry. I might just be a hopeless case. I appreciate your patience. You've gone above and beyond :slight_smile:


https://drive.google.com/file/d/0Byp-tk6B1JIbUWZ5VDNYbkVMWXdjVGV3YWJIZTdsMVIzTnpn/view?usp=sharing


#11

Okay, now we're on the same page. I see that your code is not complete and you still need to carry out step 3.

I cannot replicate the starting conditions for lesson 2, but in it we linked to the JavaScript file, main.js and in it, if I recall, wrote an alert message:

alert('Hello JavaScript!');

Step one above asks us to remove this message, but then in step three we are asked to put it back in, with a different argument, namely the object you created in the first line of code.

alert( ... );

What should go in as the argument?


#13