Map areas Collection [index] - Get the URL of the first <area> element in an image-map: - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Map

Description

Map areas Collection [index] - Get the URL of the first <area> element in an image-map:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<img src="http://java2s.com/resources/a.png" width="145" height="126" alt="" usemap="#myMap">

<map id="planetmap" name="planetmap">
  <area shape="rect" coords="0,0,80,130" alt="" href="">
  <area shape="circle" coords="90,60,5" alt="" href="">
  <area shape="circle" coords="120,60,10" alt="" href="">
</map>/*from w  w w.j  a v  a 2  s .c  om*/

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {
    var x = document.getElementById("planetmap").areas[0].href;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

Related Tutorials