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 Getting Values from Form Fields

Simtion Rares
Simtion Rares
800 Points

Selc the heading text with class of .profile-name,Use jQ text() method to set content of .profile-name to input of input

Am I doing it right?

index.html
<!DOCTYPE html>
<html lang="en">
<head>
    <title>Document</title>
</head>
<body>
    <h2 class="profile-name">Treasure Porth</h2>
    <p class="profile-text">I am a web developer!</p>

    <label>Change name:<input id="name-input" type="text"></label>
    <button>Change</button>

    <script
    src="jquery-3.2.1.min.js"></script>
    <script src="app.js"></script>
</body>
</html>
app.js
$('button').click(function() {
  const newName = $("#name-input").val();
  const prof = $('.profile-name').val();
  $('#name-input').text(prof);

});

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! You did terrific on the first step, but I feel like there might be a misunderstanding on the second step. The challenge never asks you to create a second variable. Instead it wants you to select the element with the class "profile-name" and change the text to match what is now stored in your newName variable.

Take a look:

$('.profile-name').text(newName);

This selects the element with the class "profile-name" and then changes the text to the string now stored in newName.

:bulb: On a side note, I see that you've asked this same question several times fairly short succession. Remember that you are posting to your fellow students. Many of us love to help out when/if we can. That being said, we live all over the world and in different time zones. A little patience goes a long way :smiley:

Simtion Rares
Simtion Rares
800 Points

Thx for the help! I am sorry for posting the question so many times I forgot to put the question in the description so that's why I did it again. My bad