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 trialMarni Ali
4,642 PointsProblems in changing the content of the element in jQuery
Hi there, I need help to take a look at my code. I can't seem to get it right. When I did a preview, it works fine. Thank you in advance.
This is was my code challenge: 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".
<!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>
jQuery('.profile-text');
const contents = "I am web developer";
$('.profile-text').html(contents);
2 Answers
Mark Sebeck
Treehouse Moderator 38,304 PointsHi Marni. While your code would work these challenges can be very picky. First of all remove your const contents and paste the string directly in the html(). And second and the one that took me a few minutes to find was in the string you are missing 'a'. It should be "I am a web developer". Keep at it! These challenges are picky but help you be more exact and improve your debugging skills.
Marni Ali
4,642 PointsHi Mark, Thank you for your help and reply. I did what you suggested by removing and pasting. But the same error still appears.
jQuery('.profile-text');
const contents = "I am a web developer";
$('.profile-text').html(contents);
Mark Sebeck
Treehouse Moderator 38,304 PointsMove your string into the HTML. Donβt use the const contents.
$('.profile-text').html(βI am a web developerβ);