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 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.