HTML and CSS Reference
In-Depth Information
var attributes = el.attributes,
values = [];
for (var i = 0; i < attributes.length; i++) {
if (attributes[i].name.indexOf('data-') === 0) {
When fully implemented in browsers, setting a dataset attribute
automatically sets the content attribute on the element giving
you a shorthand syntax for setting custom data. So instead of
having to do
element.setAttribute('data-author', 'Remy and Bruce');
Yo u c a n s i m p l e e x e c u t e = 'Remy and Bruce';
This syntax will automatically set the attribute on the DOM node
as well as change the property.
NoTE Custom data attri-
butes are only meant for
passing information to the site's
own scripts, for which there are
no more appropriate attributes
or elements. The spec says
“These attributes are not
intended for use by software
that is independent of the site
that uses the attributes” and are
therefore not intended to pass
information to crawlers or third-
party parsers. That's a job for
microformats, Microdata,
or RDFa.
draggable indicates that the element can be dragged using the
drag-and-drop API (see Chapter 8).
This hidden attribute is analogous to aria-hidden , which tells the
browser that the content of this element shouldn't be rendered
in any way. It hides the content, but keeps it “in the wings,” so
that, for instance, you could use JavaScript later on to remove
the attribute and cause the element to “pop” into being.
Quoting the specification (rather than attempting to paraphrase
it any further): “The hidden attribute must not be used to hide
content that could legitimately be shown in another presenta-
tion. For example, it is incorrect to use hidden to hide panels in
a tabbed dialog, because the tabbed interface is merely a kind
of overflow presentation—one could equally well just show all
the form controls in one big page with a scrollbar. It is similarly
incorrect to use this attribute to hide content just from one pre-
sentation—if something is marked hidden, it is hidden from all
presentations, including, for instance, screen readers.”
Search WWH ::

Custom Search