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 trialXun Huang
Web Development Techdegree Graduate 18,515 PointsProject 7 --the "Name" field
The "Name" field When the page first loads, the first text field should have the focus state by default to prompt the user.
Set the focus property to true on the <input type="text"> element for the "Name" field.
html :
<input type="email" id="email" name="user-email" class="error-border">
my code:
const name = document.getElementById('name');
name.setAttribute('autofocus', true);
I can see it added autofocus attribute to input element in the console, but it didn't work, and I tried using 'focus', it didn't either
1 Answer
Steven Parker
231,248 PointsThe HTML doesn't show any element with an ID of "name", is some of the code missing?
More information would be helpful, like a link to the course page. Take a look at this video about Posting a Question.
Also, when posting code, use Markdown formatting to preserve the code's appearance.