Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript JavaScript and the DOM (Retiring) 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

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 90,705 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"]')