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

Nathan Marshall
Nathan Marshall
6,031 Points

Have I done something wrong here? I have checked multiple times, I don't think I have?

I know the prior question requested .text() but I am sure that this one is asking for .html() I have added the span, I'm sure that this is correct, or have I made a silly mistake?

Please assist.

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") .html( "Student <span>Profile</span>");

1 Answer

Alexandra Edwards
Alexandra Edwards
4,686 Points

Hey Nathan, I just realized you may were asking about a different part of this challenge than I originally gave an answer for. Just in case, I will mention that Treehouse is picky about capitalization with strings they ask you to use sometimes, so here is part 2 of that challenge:

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

and part 3 you are actually just deleting-one-space away from having it correct.

$(".profile-text").text("I am a web developer");
$(".profile-header").html("Student <span>Profile</span>"); 

Hope that helps!

Nathan Marshall
Nathan Marshall
6,031 Points

Thank you very much, Alexandra your comment is appreciated!

Alexandra Edwards
Alexandra Edwards
4,686 Points

You're welcome Nathan! Best wishes and enjoy learning JavaScript. :)