Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
We would have to use htmlFor, and that would work. But for any of those attributes names that have funky names because they might be reserved words, it's easier to use some of these other functions. So, let's try getting the attribute for for, we'll use myNode and say getAttribute (SOUND) and type in for. That gives me the same thing, and I didn't have to remember the weird name, html4. To set an attribute, you can pass it to parameters. So let's go ahead and change this for attribute to something else.
We'll use set attribute, and we'll pass it the four value because we want to change the for attribute, and then we'll just set it to something else. Hit Return and pull out myNode again. And now you can see that it has the value somethingelse. In addition to that, you can find out if a node has an existing attribute with the hasAttribute function. So we use myNode and ask if it has an attribute of ID. And, of course, that returns false because it doesn't have an attribute of ID.
So, sometimes it's just easier to use these methods.
Get unlimited access to all courses for just $25/month.Become a member
61 Video lessons · 100064 Viewers
56 Video lessons · 113115 Viewers
71 Video lessons · 81972 Viewers
131 Video lessons · 39328 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.