Get Area Element - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Area

Introduction

The Area object represents an HTML <area> element.

You can access an <area> element by using getElementById():

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<img src="http://java2s.com/resources/c.png" width="100" height="100" usemap="#planetmap">

<map name="planetmap">
  <area id="myArea" shape="circle" coords="120,50,10" alt="alt message" href="http://java2s.com">
</map>/*from w  w  w.  j  a  v a 2  s . c om*/

<button onclick="myFunction()">get the URL of the area</button>

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

<script>
function myFunction() {
    var x = document.getElementById("myArea").href;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

Related Tutorials