Javascript examples for DOM:Document getElementsByClassName
getElementsByClassName to get element by class value
<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 va2s. c om var results = document.getElementsByClassName("myClass"); for (var i = 0; i < results.length; i++) { results[i].style.display = 'none'; } } </script> </head> <body> <div class="myClass"> Test </div> <div class="myClass"> Test </div> </body> </html>