get attributes from html element javascript code example
Example 1: how to get element by attribute value in javascript
document.querySelectorAll('[data-foo="value"]');
Example 2: js getattribute
const link = document.querySelector('a');
console.log(link.getAttribute('href'));