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 Introduction to jQuery Hello, jQuery! Selecting Page Elements with jQuery

2 Answers

Steven Parker
Steven Parker
231,172 Points

Sure, that will select the first li element on the page. But by itself, it won't do anything — were you thinking of using it as part of an assignment or other statement?

Vic Mercier
Vic Mercier
3,276 Points

What do you mean by were you thinking of using it as part of an assignment or other staement?

Vic Mercier
Vic Mercier
3,276 Points

I've tried :jQuery("li")[0].text("JavaScript");//It doesn't work

Steven Parker
Steven Parker
231,172 Points

That won't work, because $("li")[0] is a plain HTML element but you're trying to use the jQuery .text method on it which is only for jQuery objects. But this woud work:

$("li")[0].textContent = "JavaScript";