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 DOM Scripting By Example Adding and Removing Names Registering Names

Ryan Schmelter
Ryan Schmelter
9,710 Points

Clearing the input field leaves the field completely empty instead of with the "Invite Someone" text.

Declaring input.value = " "; completely clears the field in my code, rather than reloading the "invite someone" text like it does in the video. The code is the same. I suppose I could just put input.value = "Invite Someone", but it won't have the same styling. Any ideas?

2 Answers

Steven Parker
Steven Parker
231,269 Points

Note that there is a difference between assigning a space (" ") to the value as compared to assigning an empty string (""). A space will be treated as content and displayed (making the box appear cleared), but an empty string will be treated as a lack of content and the placeholder will be displayed instead.

Ryan Schmelter
Ryan Schmelter
9,710 Points

Very good to know. Thanks, Steven.

I see... so there's a difference...