There are no tracking or monitoring cookies on this site. There are only cookies used for documentation examples related to cookies.
Close

Processing...
This may take a few seconds.

set-attribute

Syntax

set-attribute: (attribute) (boolean|"string") [every (time)] [after (time)][, (attribute)...];

This command adds a new attribute into the target selector if it doesn't exist, or replaces an attribute if it is already there.

The attribute parameter is the name of the attribute you want to use.

The boolean parameter accepts "true" or "false", if your attribute is either true or false. You can leave out the double-quotes for a boolean. Or alternatively, the string parameter is what you want to have inside the attribute. It requires double-quotes - these are currently not optional.

For some of the difference between properties and attributes and recommended use, see this page:

https://www.joji.me/en-us/blog/html-attribute-vs-dom-property/

set-attribute