<!DOCTYPE html>
<html>
<head>
<script>
function showDetails(animal) {
    var animalType = animal.getAttribute("data-animal-type");
    alert("The " + animal.innerHTML + " is a " + animalType + ".");
}
</script>
</head>
<body>

<h1>Species</h1>
<p>Click on a species to see what type it is:</p>

<ul>
  <li onclick="showDetails(this)" id="owl" data-animal-type="bird">Owl</li>
  <li onclick="showDetails(this)" id="salmon" data-animal-type="fish">Salmon</li>  
  <li onclick="showDetails(this)" id="tarantula" data-animal-type="spider">Tarantula</li>  
</ul>
<h2 onclick="showDetails(this)" data-animal-type="第2级标题的子标题">第2级标题</h2>
</body>
</html>

 

相关文章:

  • 2021-12-28
  • 2021-07-23
  • 2021-05-24
  • 2021-10-10
  • 2022-12-23
  • 2022-12-23
  • 2021-07-08
  • 2021-09-03
猜你喜欢
  • 2022-02-08
  • 2022-12-23
  • 2022-12-23
  • 2022-02-08
  • 2021-12-27
  • 2021-06-26
  • 2021-08-29
相关资源
相似解决方案