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 jQuery Basics Introducing jQuery Using text() and html()

Michael Wilkens
Michael Wilkens
7,976 Points

Quiz not functioning properly

You're asked to select the h1 element with class profile-header, however the quiz returns an error, saying you should have selected profile-text, the class of the <p> element from the previous question.

index.html
<!DOCTYPE html>
<html lang="en">
<head>
    <title>Document</title>
</head>
<body>
    <h1 class="profile-header"></h1>
    <p class="profile-text"></p>

    <script
    src="jquery-3.2.1.min.js"></script>
    <script src="app.js"></script>
</body>
</html>
app.js
$('.profile-header').text("I am a web developer")

3 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there, Michael Wilkens ! The challenge seems to be working fine. I think there might be a misinterpretation of the instructions here. Step 1 and Step 2 are all about the paragraph with the class .profile-text, but the third step asks you to select the .profile-header and change its contents. To be clear, you will need two lines of code. You changed your previous selector from profile-text to profile-header.

Take a look at this important information from the challenge:

Important: In each task of this code challenge, the code you write should be added to the code from the previous task.

You were not meant to alter your code from the previous step unless it explicitly says so.

Hope this helps! :sparkles:

Harshay Raipancholi
seal-mask
.a{fill-rule:evenodd;}techdegree
Harshay Raipancholi
Python Development Techdegree Student 11,508 Points

Hi Mate,

The following code (solution) will work fine :

$(".profile-text").text("I am a web developer");

There are a number of differences I see in your code. Firstly, you haven't ended the statement with a colon and you are using single quotes instead of double. Try changing this and it should work fine.

Jennifer Nordell
seal-mask
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

The use of single quotes or double quotes makes absolutely no difference to JavaScript :smiley:

Harshay Raipancholi
seal-mask
.a{fill-rule:evenodd;}techdegree
Harshay Raipancholi
Python Development Techdegree Student 11,508 Points

hmm... okay I see, in that case his code should've worked fine, it worked fine with my solution. Why is michael's code not working?

Thanks!

Jennifer Nordell
seal-mask
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

shay r because I believe he is on the third step, but instead of adding a new line of code to select the headline, he changed the original line to select the headline. The first line of code should select the paragraph. The second line of code should select the headline :smiley: Note in his question that it says the instructions say to select the h1 element, but that instruction doesn't come until Step 3

Michael Wilkens
Michael Wilkens
7,976 Points

Hi all,

Jennifer was right; although I had typed the code correctly for step 3, the question wanted to keep the code from step 2 in the workspace and then type in the code for step 3.

Thanks!