Student-friendly HTML, CSS, and JavaScript reference with examples
Gets the value of an HTML attribute.
const button = document.querySelector('button');
const tabId = button.getAttribute('data-tab');
const href = link.getAttribute('href');
Commonly used with data attributes to store custom information on elements.