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

Jack Cummins
Jack Cummins
17,417 Points

Please Help Me With This Code Challange P.S. I give out best answers

Challenge Task 2 of 3
You've just learned how to use the jQuery methods text() and html(). Use the appropriate jQuery method to set the contents of the $('.profile-text') element to "I am a web developer".

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-text").text("I am a Web Developer");

4 Answers

The only reason you are getting the error is because treehouse is being picky about the capitalisation inside the string used in the text() method. Just make the W in web and D in developer lowercase and it will pass, like this:

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

It's very peculiar that Treehouse won't accept this yet the preceding exercise recommended this format as best practice:

const content = "I am a web developer.";
$('.profile-text').text(content);
Patrick Vass
Patrick Vass
7,621 Points

I tried multiple versions including this one and it still throws up an error that task one is no longer passing but it is. Please some advice on the matter?

If it is saying that task one is failing that is usually a sign off a syntax error. Can i have a snippet of your code to look at?

i'm having the same challenge as yours Patrick Vass

Patrick Vass
Patrick Vass
7,621 Points

Thanks Connor Walker for pointing out the obvious, I checked again and it was a syntax error and I passed the challenge

Could you please show me what you did. I got thru the first part but for the second half I have hit a wall... Please help!

you got to comment out line 2 and it should look like this

jQuery(".profile-header"); //jQuery(".profile-text");

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