getAttribute

Get an attribute from an DOM-element based on the selector and attribute name. Returns a list of attribute values if selector matches multiple elements.

Usage

1
client.getAttribute(selector,attributeName).then(callback);

Parameters

Param Type Details
selector String element with requested attribute
attributeName String requested attribute

Example

index.html
1
2
3
<div data-type="example" id="elem">
Lorem ipsum dolor ammet
</div>
getAttribute.js
1
2
3
client.getAttribute('#elem', 'data-type').then(function(attr) {
console.log(attr); // outputs: "example"
});

Uses