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 trialAtri Banerjee
3,431 PointsYou'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>".
<!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>
$('.profile-text').text("I am a web developer");
Raedawn Long
6,943 PointsI realized I forgot a closing parenthesis after I posted.
Thank you
11 Answers
Prsicilla Anesu Muzerengwa
12,577 Points$('.profile-header').html("Student <span>Profile</span>");
Steven Parker
231,236 PointsExplicit answers without any explanation are strongly discouraged by Treehouse and may be subject to redaction by moderators.
Dave Harker
Courses Plus Student 15,510 PointsHi Atri Banerjee,
You're doing great! For the next part you'll need to:
select the h1 element by its class name and set its contents to "Student <span>Profile</span>"
The 'gotcha' here it seems is you need to remember to use .html() instead of the .text() you used in the previous task. Also, remember to leave your previous code in the .js file as this challenge continues on rather than replaces previous code.
Let's get to it.
select the h1 element by its class name
Selecting the h1 element is done just like the p element in the previous task, except you'll need to get the class name for the h1 element this time, and use that.
$(".class name here")
Now let's
set its contents to "Student <span>Profile</span>"
Remeber to use .html() instead of .text(). We can accomplish this with the following:
.html("string with HTML embedded here");
Now you'll just need to put that all together, and you've got it!
Happy coding,
Dave
Austin Jones
8,305 PointsThe problem is that the task is just plain broken. It will not accept the correct answer...
Steven Parker
231,236 PointsTry creating a fresh question and including your code with it so folks can help you determine the issue.
HIDAYATULLAH ARGHANDABI
21,058 Pointsthank you steven
harpreet singh gill
2,559 Points$('.profile-header').html("Student<span>profile</span>");
Steven Parker
231,236 PointsClose, but you need a space between "Student" and "<span>".
Eyanjem Etta-Ashu
Full Stack JavaScript Techdegree Graduate 18,260 PointsI had same issue but this worked don't put a between the code that goes in the html like this .html("Student<span>profile</span>").
Ivy Cerelle Gray
21,328 Points$('.profile-header').html("Student <span>Profile</span>");
I typed in this, and I am getting an error. What am I doing wrong?
Steven Parker
231,236 PointsLeaving a question as an "answer" to someone else's question!
But you may have erased your task 2 code when you did task 3. They both must be present to pass. If that's not it, start a fresh new question.
Ivy Cerelle Gray
21,328 PointsHaha. I didn't realize someone else asked the same question AND I "answered" it. And yes, I figured it out! I deleted the previous step. Oops! Thanks for answering my question!
matt anderson
Full Stack JavaScript Techdegree Student 10,777 PointsWhy do you need the space after Student?
Phillip Roberts
991 PointsIt appears the correct solution to this problem is still broken. I've submitted the code below and getting the error Bummer: Did you call jQuery with the selector ".profile-text"?
$('.profile-header').html("Student <span>Profile</span>");
Steven Parker
231,236 PointsPerhaps you missed the instruction that said "Important: In each task of this code challenge, the code you write should be added to the code from the previous task."
Your line is correct for task 3, but it must be added after the line created for task 2 (and the task 2 line must still be there).
Kyle Salisbury
Full Stack JavaScript Techdegree Student 16,363 PointsFor those struggling on this, you need to keep $('.profile-text').text("I am a web developer"); above your answer of $('.profile-header').html("Student <span>Profile</span>");
Steven Parker
231,236 PointsSteven Parker
231,236 PointsIt doesn't look like you've written any code yet for task 3. At least please give it your best "good faith" try and then ask for help if you have trouble.