Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Start a free Courses trial
to watch this video
HTML tags are converted into objects (called nodes) and placed into the DOM. Attributes exist as properties of element objects, like the href
attribute of an <a>
element or the action attribute of a <form
> element. You get or set those attributes by way of properties, similar to the way you did earlier with an input element's value
property and a heading's textContent
property.
Further Reading and Related Videos
className
The className
property overwrites any existing classes on an element. When dealing with multiple classes on an element, the classList
property offers a convenient alternative to accessing an element's list of classes.
Get and set attributes with JavaScript
The getAttribute and setAttribute methods provide alternative ways to manage element attributes.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up