Map name Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Map

Description

The name property sets or gets the name attribute of an image-map.

Set the name property with the following Values

Value Description
name Sets the name of an image-map

Return Value

A String, representing the name of the image-map

The following code shows how to get the name of 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="alt message" usemap="#myMap">

<map id="myMap" name="myMap">
  <area shape="rect" coords="0,0,82,110" alt="rect" href="http://java2s.com">
  <area shape="circle" coords="90,60,5" alt="circle1" href="http://java2s.com">
  <area shape="circle" coords="125,60,10" alt="circle2" href="http://java2s.com">
</map>/*  w w  w . j a va  2 s . com*/

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

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

<script>
function myFunction() {
    var v = document.getElementById("myMap").name;
    document.getElementById("demo").innerHTML = v;
}
</script>

</body>
</html>

Related Tutorials