js dom attribute value code example Example: get element attribute javascript var x = document.getElementsByTagName("H1")[0].getAttribute("class");