Set or get HTML attributes on one or more elements.
Provides a unified interface for attribute manipulation, mirroring the css() pattern with .remove() and .has() methods.
css()
.remove()
.has()
attr(el, { 'data-id': '123', role: 'button' }); attr(el, 'role'); // → 'button' attr(el, ['role', 'data-id']); // → { role: 'button', 'data-id': '123' } attr.remove(el, 'role'); attr.has(el, 'disabled'); // → boolean Copy
attr(el, { 'data-id': '123', role: 'button' }); attr(el, 'role'); // → 'button' attr(el, ['role', 'data-id']); // → { role: 'button', 'data-id': '123' } attr.remove(el, 'role'); attr.has(el, 'disabled'); // → boolean
Check whether an element has a specific attribute.
attr.has(el, 'disabled'); // → true Copy
attr.has(el, 'disabled'); // → true
Remove one or more attributes from one or more elements.
attr.remove(el, ['role', 'data-id']); attr.remove([el1, el2], 'role'); Copy
attr.remove(el, ['role', 'data-id']); attr.remove([el1, el2], 'role');
Set or get HTML attributes on one or more elements.
Provides a unified interface for attribute manipulation, mirroring the
css()pattern with.remove()and.has()methods.