From the course: JavaScript: Enhancing the DOM (2013)
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Detecting data attributes
From the course: JavaScript: Enhancing the DOM (2013)
Detecting data attributes
In an HTML document, a developer can type in any attributes, even if they don't necessarily exist and pretend they're valid HTML. The browsers usually ignore them, but validaters will flag these as not being normal HTML. This is the HTML for the document we've been working with. And if I want to, I can add a coolness attribute here and set it to whatever I want. Now, the browser is probably going to ignore this attribute and not do anything with it, but if I try to validate my document. I want to copy this and I'll switch over to the WC3 validater. And I'll click on the Validate By Direct Input tab, and paste my code right there. And I'll hit the Check button, you could see that it's telling me that there's at least one error there. Let me scroll all the way to the bottom, and notice that it says attribute coolness not allowed on element image at this point. It really means that it doesn't know anything about this new attribute that I just invented. So, thankfully HTML5 provides a way…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
(Locked)
Changing HTML attributes5m 25s
-
(Locked)
Working with restricted attributes2m 49s
-
(Locked)
Detecting data attributes3m 29s
-
Controlling classes with the HTML5 classList3m 21s
-
(Locked)
Targeting the attributes property1m 24s
-
(Locked)
Using text content modifiers3m 42s
-
(Locked)
Modifying elements as text2m 15s
-
(Locked)
-
-
-