WeprovideTutorials!

"/> WeprovideTutorials!

">

Home  >  Article  >  Web Front-end  >  How to add a unique identifier to an element in HTML?

How to add a unique identifier to an element in HTML?

WBOY
WBOYforward
2023-09-01 11:37:061390browse

How to add a unique identifier to an element in HTML?

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

Example

You can try running 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>

The above is the detailed content of How to add a unique identifier to an element in HTML?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete