Javascript examples for DOM:Element getAttribute
Get and set tag attribute via Element object
<html> <head> <title>MySite</title> </head> <body> <div id="mydiv" testarg="teststring"></div> <script> var element = document.getElementById("mydiv"); var argstring = element.getAttribute('testarg'); console.log(argstring); element.setAttribute('testarg', 'changed'); console.log(element.getAttribute('testarg')); </script> </body>//from w w w. j av a 2 s . co m </html>