<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <script> function showDetails(animal) { var animalType = animal.getAttribute("data-animal-type"); alert(animal.innerHTML + "是一种" + animalType + "。"); } </script> </head> <body> <h1>物种</h1> <p>点击某个物种来查看其类别:</p> <ul> <li οnclick="showDetails(this)" id="owl" data-animal-type="鸟类">喜鹊</li> <li οnclick="showDetails(this)" id="salmon" data-animal-type="鱼类">金q鱼</li> <li οnclick="showDetails(this)" id="tarantula" data-animal-type="蜘蛛">蝇虎</li> </ul> </body> </html>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)