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

nathan goel
nathan goel
7,281 Points

I try to use document.querySelector with a title attribute, it returns null in console. I don't see what I missed there.

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!!

2 Answers

Courses Plus Student 22,431 Points

I was getting the same error 'the value null for the query selector'.

Then I realized I had saved the file app.js but forgot to refresh the browser for the changes to reflect in the DOM.

Thank You! I was stuck too then I read your answer, Oh the simple stuff still gets me haha

Jonathan Grieve
Jonathan Grieve
Treehouse Moderator 87,800 Points

It looks like your CSS query in your method isn't quite right.

In the absence of a link I can only make a best guess as to the exact selector you need but try passing the following in your querySelector method.