JavaScript JavaScript and the DOM Getting a Handle on the DOM Using CSS Queries to Select Page Elements

Fabian Pijpers
PLUS
Fabian Pijpers
Courses Plus Student 35,876 Points

When using the exact same syntax you use in the video's i get a null returned! Do you know why?

document.querySelector('[title=label]') it returned the: null

The above is what i entered into the developer console.

Adam Beer
Adam Beer
11,288 Points

Please show your code.

3 Answers

Adam Beer
Adam Beer
11,288 Points

Try this Nathan,

document.getElementsByClassName("textDesign")

or

document.querySelector('[title="firstParagraph"]')

If it doesn't work please show your whole html/javascript code.

Martin Lecke
Martin Lecke
14,363 Points

Hi

You have missed one step in the video if you are tagging along the code-along.

On the 02:03 minute mark he adds the title="label" on the html tag. You dont have it in your html else you might have misspelled it. Check the video at 02.03

nathan goel
nathan goel
7,281 Points

Same kind of issue for me. Here is my code in the html page: <p title="firstParagraph" class="textDesign"> Lorem ipsum dolor sit amet, consectetur adip... </p>

That is the result in the console:

document.querySelector('[title=firstParagraph]') null

Help, please!!