Javascript examples for DOM:Element setAttribute
assign a variable to html element object
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){/* www . j av a 2s .c o m*/ var elem = document.getElementById('questions'); console.log(elem.getAttribute('data')); elem.setAttribute('data', 'newValue.html'); console.log(elem.getAttribute('data')); } </script> </head> <body> <object id="questions" width="400" height="400" data="home.html"> </object> </body> </html>