JavaScript jQuery Basics Introducing jQuery Using text() and html()

Kathryn Notson
Kathryn Notson
25,941 Points

jQuery Basics > Introducing jQuery > Using text() and html()

This isn't functioning the way it's supposed to do on Challenge Task 2 of 3. The code appears correct.

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.");

2 Answers

Steven Parker
Steven Parker
142,115 Points

The challenges can be very picky about message contents!

The instructions say to set the contents of the ... element to "I am a web developer" :point_left: Note: there is no period in the message.

Carlos Morales
Carlos Morales
1,595 Points

Hi Steven i'm having trouble with the task 3 that follows this one i'm using this code and it keeps giving me and error like if it's wrong $(".profile-header").html("Student <span>Profile</span>");

Oh i didn't leave the previous code i just erased it. That worked i need to read more. Thanks Steven

Steven Parker
Steven Parker
142,115 Points

Your code looks good. :+1: Did you possibly overlook 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."

If you replaced the task 2 code instead of adding this to it, that may be the issue.

Also, for future issues, always start a new question instead of adding one as an "answer" to an old one. Otherwise, your question might only be seen be the few people who asked/answered the old question.

Kathryn Notson
Kathryn Notson
25,941 Points

Steven Parker:

Yes, I just figured it out on my own just before you emailed your response. More careful reading needed on my part. Instructors are VERY PARTICULAR & EXACTING with their answers to challenges.