我的HTML元素:
<img src ="planets.gif" width="145" height="126" alt="Planets"
usemap="#planetmap">
<map name="planetmap">
<area shape="rect" coords="0,0,82,126" href="sun.htm" alt="Sun">
<area shape="circle" coords="90,58,3" href="mercur.htm" alt="Mercury">
<area shape="circle" coords="124,58,8" href="venus.htm" alt="Venus">
</map>
如何使用Javascript获取coords
元素中包含的每个区域形状的map
?
答案 0 :(得分:1)
你可以试试这样的......
var coords = [];
[].forEach.call(document.querySelectorAll("area"), function (value, index, array) {
coords.push(value.getAttribute("coords").split(","));
});