How do we embed custom data attributes on all HTML elements?

HTMLWeb DevelopmentFront End Technology

Use the data-* attribute to embed custom data attributes. It consists of the attribute, which should not contain any uppercase letter and should get prefixed after data.


<!DOCTYPE html>
         function display(rank) {
            var myRank = rank.getAttribute("data-rank-type");
            alert("Rank " + rank.innerHTML + " has " + myRank + " points.");
      <h1>Rank and Points</h1>
      <p>Click on any rank to generate the details.:</p>
         <li onclick = "display(this)" id = "fifth" data-rank-type = "500">Fifth</li>
         <li onclick = "display(this)" id = "sixth" data-rank-type = "600">Sixth</li>
Updated on 03-Mar-2020 05:37:22