Latest web development tutorials

HTML DOM Map areas set

Map Object Reference Map Object

Examples

Get the number of image map <area> element:

var x = document.getElementById ( "planetmap") areas.length.;

x output values:

3

try it"

Definitions and use

areas set to return a collection of all <area> element of the image map.

Note: The elements of the collection sorted in source code order.

Tip: If you need to return a set of attributes href all <area> element is specified, 'You need to use the links collection.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the collection areas.


grammar

mapObject .areas

Attributes

Attributes description
length Returns the number of the collection <area> element

method

method description
[Name_or_index] String or integer that specifies the element to retrieve (index starting with 0)
item(name_or_index) Returns the index / name / id of the element from the collection
namedItem(name_or_id) Returns the specified name from the collection of elements (name or id attribute)


More examples

Examples

[Name_or_index]

Get a map image URL first <area> element:

var x = document.getElementById ( "planetmap") areas [0] .href.;

try it"

Examples

item (name_or_index)

Get a map image URL first <area> element:

var x = document.getElementById ( "planetmap") areas.item (0) .href.;

try it"

Examples

namedItem (name_or_id)

Acquiring an image map id = "myArea" of <area> element URL:

var x = document.getElementById ( "planetmap") areas.namedItem ( "myArea") href..;

try it"

Examples

Get in shape image map all <area> element:

var x = document.getElementById ( "planetmap");
var txt = "";
for (var i = 0; i <x.areas.length; i ++)
{
txt = txt + x.areas [i] .shape + "<br>";
}
document.getElementById ( "demo") innerHTML = txt.;

try it"


Map Object Reference Map Object