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 trialThomas Scott
7,682 PointsDoes input.type only work if you have "selected" it beforehand in the code with the document.querySelector() ?
Or does it work because you defined the variable "input" by selecting it ?
if you had defined the variable input2 = document.querySelector('input'); would the javascript code need to be adjusted to input2.type in the console in order to bring the value of the type?
2 Answers
Steven Parker
231,261 PointsThe querySelector method gives you a reference to the element itself. If you then want to access a property of the element, you attach the property using the membership operator (period), as in your example of input2.type
to reference the "type" property.
Thomas Scott
7,682 PointsThanks !