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
Seth Pabst
10,285 PointsWhy cant I use the .text(); method the same way I use the .val(); method? they both grab what's inside the element
this pertains to jQuery btw
1 Answer
Adam Pengh
29,881 PointsThe text() method is used to get or set the text inside the opening and closing tags of an element, such as:
<p>This is the text</p>
The val() method is primarily used for getting or setting the value of an input.
<input type="text" value="This is the value">