How to specify a unique id for an element in HTML?

HTMLWeb DevelopmentFront End Technology

Use the id attribute in HTML to specify a unique id for an element in HTML.

Example

You can try to run the following code to implement the id attribute −

<html>
   <body>
      <h1>Tutorialspoint</h1>
      <p id = "myid">We provide Tutorials!</p>
      <button onclick="display()">More...</button>
      <script>
         function display() {
            document.getElementById("myid").innerHTML = "We provide learning videos as well";
         }
      </script>
   </body>
</html>
raja
Published on 14-Mar-2018 12:35:27
Advertisements