简单教程
提交运行
代码编辑器:
<img src="/static/i/img1.jpg" width="145" height="126" alt="Planets" usemap="#planetmap"> <map name="planetmap" id="planetmap"> <area shape="rect" coords="0,0,82,126" alt="Sun" href="/static/i/html/sun.html"> <area shape="circle" coords="90,58,3" alt="Mercury" href="/static/i/html/sun2.html"> <area shape="circle" coords="124,58,8" alt="Venus" href="/static/i/html/sun2.html"> </map> <p>点击按钮获取图像地图中的 area 元素的URL</p> <p id="demo"></p> <button onclick="myFunction()">点我</button> <script> function myFunction(){ var x = document.getElementById("planetmap").areas[0].href; document.getElementById("demo").innerHTML = x; } </script>
运行结果: