Javascript examples for DOM HTML Element:Style
Replace class name for element without ID
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){//from ww w . ja v a 2 s . c om function replaceClass() { var plusLinks = document.querySelectorAll('.my'); var firstLink = plusLinks[0]; firstLink.setAttribute('class', 'yourClassName'); } replaceClass(); } </script> </head> <body> <div class="my"> TEST TEST </div> </body> </html>