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

Jonathan Grieve
Jonathan Grieve
Treehouse Moderator 84,036 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.

Full Stack JavaScript Techdegree Student 15,596 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.