how to get an attribute from a document code example
Example 1: javascript element read attribute
document.getElementById('id1').getAttribute('attribute');
Example 2: how to get element by attribute value in javascript
document.querySelectorAll('[data-foo="value"]');