Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript Interactive Web Pages with JavaScript Selecting Elements and Adding Events with JavaScript Selecting Elements

Jeremy King
Jeremy King
3,232 Points

Task 1 is no longer passing. but my syntax looks correct. . .

I'm selecting the ID and the Class, But it's telling me that the first one is no longer passing, when it was correct before, and didn't change between challenges.

app.js
var fullName = document.getElementById('full_name');
var lastName = document.getElementsbyClassName('last_name');
index.html
<!DOCTYPE html>
<html>
<head></head>
<body>
<h1 id="full_name"><span class="first_name">Andrew</span> <span class="last_name">Chalkley</span></h1>

<script src="app.js"></script>
</body>
</html>

1 Answer

Stephen Gheysens
Stephen Gheysens
11,935 Points

Hi Jeremy,

I actually caught this because I messed up while testing my answer for Task 1: you used var lastName = document.getElementsbyClassName('last_name'); but note that the function name has a capitalized 'B' in "By". Also note that this function returns an array of elements and you'll need to access the first one (index 0). Let me know if you have any trouble with that!

Thanks, Stephen

Jeremy King
Jeremy King
3,232 Points

Thanks, I also needed to switch it over to TagName. I'm surprised that the lowercase b in "by" broke it to saying that task one was no longer passing. But, anyway, that fixed it, thanks.