运行 ❯
获取您的
自己
网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <body> <h3>A demonstration of how to access a MAP element</h3> <img src="planets.gif" width="145" height="126" alt="Planets" usemap="#myMap"> <map id="myMap" name="myMap"> <area shape="rect" coords="0,0,82,126" alt="Sun" href="sun.htm"> <area shape="circle" coords="90,58,3" alt="Mercury" href="mercur.htm"> <area shape="circle" coords="124,58,8" alt="Venus" href="venus.htm"> </map> <p>Click the button to get the number of area elements in the image-map.</p> <button onclick="myFunction()">Try it</button> <p id="demo"></p> <script> function myFunction() { var x = document.getElementById("myMap").areas.length; document.getElementById("demo").innerHTML = x; } </script> </body> </html>