Type of element to select attribute from.
Attribute name to include in the selector.
Optional
value: null | AttributeValue = undefinedOptional attribute value to include in the selector.
Optional
tagName: stringOptional tagName name to include in the selector.
CSS selector based on the attribute name
and optional value
and tagName
.
InvalidAttributeError
if the specified value
could not be stringified.
Name Only
selectAttribute("disabled");
// [disabled]
Name and Value
selectAttribute("disabled", true);
// [disabled="true"]
Name, Value, and Tag
selectAttribute("disabled", true, "button");
// button[disabled="true"]
Name and Tag (No Value)
selectAttribute("disabled", null, "button");
// button[disabled]
Attempts to build a CSS selector string from the attribute
name
andvalue
. Note that thevalue
is coerced to a string andnull
excludes a value but only includes a name. IftagName
is specified, it is included in the resulting selector.If you specify the optional
E
generic, you'll get autocomplete on the attributes for the element associated with that type.