Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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

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

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
MOD
Jonathan Grieve
Treehouse Moderator 91,253 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.

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