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 AJAX Basics (retiring) AJAX and APIs Review Making JSON Requests with jQuery

m lost here

how do i fill in that

Grace Kelly
Grace Kelly
33,990 Points

What question are you stuck on??

7 Answers

Christian Vann
Christian Vann
9,021 Points

The Question: Finish the code below to retrieve the text inside an HTML element with the ID of "button" and store it in the variable "animal":

Answer: .text()

John Grillo
John Grillo
30,241 Points

why just '.text()' and not 'this.text()'?

This should work - - var animal = $('#button').text();

If you mean the question: Finish the code below to retrieve the text inside an HTML element with the ID of "button" and store it in the variable "animal"

... then it's asking you to use a jQuery method to get the text content of an element. The selector for the element with the ID of button has already been completed for you. Try searching through the jQuery documentation to find the method you need: https://api.jquery.com/

So you just need the method name followed by a set of parentheses:

methodName()

None of these answers seem to work. I'm completely stuck on the same thing.

.text() worked for me

text() is the right answer

Sandeep Krishnan
Sandeep Krishnan
9,730 Points

try this - var animal = $('#button').text('animal');