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

$('.profile-header').html('Student <span>Profile</span>'); should be an answer as per task

Student <span>Profile</span>, content is being displayed by html method, in h1 selector, as above syntax code but it's not accepting the answer as true, what is the answer for this ?

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');
$('.profile-text').text('Student <span>Profile</span>');

1 Answer

Steven Parker
Steven Parker
229,732 Points

It looks like you got tasks 2 and 3 mixed up with each other. Task 2 says "set the contents of the $('.profile-text') element to "I am a web developer".", but this code is setting that string to the $('.profile-header') element instead.

There's a similar mix-up with the task 3 element and contents.

Also, for task 3, you'll need to set the "html" property instead of "text" since the content contains formatting tags.