BootWiki教程网
源代码:
点击运行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>BootWiki 教程网</title> </head> <body> <h3>以下实例演示了如何访问 MAP 元素</h3> <img alt="Planets" height="126" src="planets.gif" usemap="#myMap" width="145"> <map id="myMap" name="myMap"> <area alt="Sun" coords="0,0,82,126" href="sun.htm" shape="rect"> <area alt="Mercury" coords="90,58,3" href="mercur.htm" shape="circle"> <area alt="Venus" coords="124,58,8" href="venus.htm" shape="circle"> </map> <p>点击按钮来获取图像地图中 area 元素的数目。</p> <p id="demo"></p> <button onclick="myFunction()">点我</button> <script> function myFunction(){ var x = document.getElementById("myMap").areas.length; document.getElementById("demo").innerHTML = x; } </script> </body> </html>
运行结果