• SQL Tutorial
  • jQuery
  • Spring
  • JSP
  • Java IO
  • Core Java
  • RubyonRails
  • PHP
  • Struts

  • <

    HTML Classes

    Class is define one or more class names for an HTML element.The class name can be used by CSS and JavaScript to do some tasks for HTML elements.

    HTML Classes Example



    
    <!DOCTYPE html>
    <html>
    <head>
    <style>
    .name {
        background-color: tomato;
        color: white;
        
        
    }
    </style>
    </head>
    <body>
    
    <h2 class="name">sunil kumar</h2>
    
    <h2 class="name">rahul yadav</h2>
    
    
    </body>
    </html>
    
    
    
    


    HTML Classes in Javascript



    
    <!DOCTYPE html>
    <html>
    <body>
    
    
    <p>Click the button hide to hide all elements with JavaScript:</p>
    
    <button onclick="hide()">Hide</button>
    
    <h2 class="name">arun</h2>
    
    
    <h2 class="name">raju</h2>
    
    <h2 class="name">sunil</h2>
    
    
    <script>
    function hide() {
      var a = document.getElementsByClassName("name");
      for (var i = 0; i < x.length; i++) {
        a[i].style.display = "none";
      }
    }
    </script>
    
    </body>
    </html>
    
    
    
    
















    © copyright 2017-2021 Completedone pvt ltd.