Javascript examples for DOM:Element setAttribute
Add new data attribute with javaScript
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){//from w w w. j a v a2 s . c o m var el = document.getElementById("test"); el.setAttribute("data-transition" , "transform: translate3d(200px,100px,0)"); console.log(el.getAttribute("data-transition")); } </script> </head> <body> <div id="test"> bla bla </div> </body> </html>