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 trialJohn Pedigo
6,337 PointsjQuery Basics Challenge 1 of 2:
- 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
Code provided: $('button').click(function)
<!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>
$('button').click(function() {
// Write code here
});
1 Answer
Michael Andreuzza
11,000 Points$('button').click(function() { const newName = $('#name-input').val(); });
This is the answer, ...but give a try firs for yourself, i just did it, for 20 minutes because it was something wrong with my code.But now its fine.
have a nice one!
Steven Parker
231,269 PointsSteven Parker
231,269 PointsIt doesn't look like you've written any code yet. At least please give it a good-faith attempt and then ask for help with a specific issue if you have trouble.