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

MOHAMMED AHMED ALNAJAR
PLUS
MOHAMMED AHMED ALNAJAR
Courses Plus Student 6,810 Points

Inside the provided click handler in app.js: Use jQuery’s val() method to get the value of the text input

Inside the provided click handler in app.js:

Use jQuery’s val() method to get the value of the text input with the ID of name-input Save it to a variable named newName

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() {
  // Write code here
    const newName = $('#name-Input').val();

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

});

1 Answer

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

Hi there! You simply have a typo. You are trying to get the id of "#text-Input", but the id is "#text-input". Note the difference in capitalization between Input and input.

When I fix the capitalization, your code passes! :sparkles: