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()

You've just learned how to use the jQuery methods text() and html(). Use the appropriate jQuery method to select the h1

You've just learned how to use the jQuery methods text() and html(). Use the appropriate jQuery method to select the h1 element by its class name and set its contents to "Student <span>Profile</span>".

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
const content="Student <span>Profile</span>";
$(".profile-header").html('content');
//I am a web developer

2 Answers

Hey Abbas,

Give this a try:

Instead of declaring a variable "content" with the content you'd like placed in the .profile-header, try doing it without a variable: "Student <span>Profile</span>"

Technically, what you're doing by declaring a variable with "Student <span>Profile</span>" is okay. However, there are two issues that I believe you're running into:

1) The test seems to be looking for you to specifically add the "Student <span>Profile</span>" string into the .html argument. Instead of creating a variable.

2) If you were to go about it the way that you're trying (which is totally okay), you'd need to remove the single quotes from 'content' and just use the the variable name content as the .html argument. Like this: $(".profile-header").html(content);

Hope that helps! Let us know if you have anymore issues/questions with this one!

thank u

Abbas fadel, if this question has been answered could you mark it as β€œanswered” for me? :) Thank you!

Tim Abbott
Tim Abbott
14,206 Points

Just stumbled over this myself. The problem is that you mustn't delete part two of the challenge, when completing part three.