Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

documentation for HTMLMapElement.areas #31713

Merged
merged 29 commits into from
Jul 13, 2024
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
229bda3
initial files
ShubhamOulkar Jan 14, 2024
3eb5952
content
ShubhamOulkar Jan 14, 2024
8a9cdfa
example
ShubhamOulkar Jan 14, 2024
2e85234
lint
ShubhamOulkar Jan 14, 2024
7f18cc2
lint
ShubhamOulkar Jan 14, 2024
85091d6
lint
ShubhamOulkar Jan 14, 2024
b061acb
lint
ShubhamOulkar Jan 14, 2024
091587b
Update files/en-us/web/api/htmlmapelement/areas/index.md
ShubhamOulkar Jan 14, 2024
3fca718
Update files/en-us/web/api/htmlmapelement/areas/index.md
ShubhamOulkar Jan 14, 2024
49545a9
Update files/en-us/web/api/htmlmapelement/areas/index.md
ShubhamOulkar Jan 14, 2024
83b50be
typo
ShubhamOulkar Jan 14, 2024
ab65d59
Merge branch 'HTMLMapElement.areas' of https://github.com/ShubhamOulk…
ShubhamOulkar Jan 14, 2024
03b7298
typo
ShubhamOulkar Jan 14, 2024
370d61b
image compression
ShubhamOulkar Jan 14, 2024
09166f4
content changes
ShubhamOulkar Jan 15, 2024
ed9cd43
Update files/en-us/web/api/htmlmapelement/areas/index.md
ShubhamOulkar Jan 15, 2024
c0cd76c
Update files/en-us/web/api/htmlmapelement/areas/index.md
ShubhamOulkar Jan 15, 2024
e4a96ea
Update files/en-us/web/api/htmlmapelement/areas/index.md
ShubhamOulkar Jan 15, 2024
77c8888
lint
ShubhamOulkar Jan 15, 2024
197ca48
Update files/en-us/web/api/htmlmapelement/areas/index.md
ShubhamOulkar Jan 16, 2024
2a9c248
Lint
ShubhamOulkar Jan 16, 2024
a4c1f21
example changes
ShubhamOulkar Jan 16, 2024
98328ab
Merge branch 'main' into HTMLMapElement.areas
ShubhamOulkar Jan 21, 2024
32ef4b1
example update
ShubhamOulkar Jan 24, 2024
4f68e5a
area target value change
ShubhamOulkar Jan 24, 2024
6df9e60
header fix
ShubhamOulkar Jan 25, 2024
0d0039b
Merge branch 'main' into HTMLMapElement.areas
estelle May 7, 2024
e05e73c
Merge branch 'main' into HTMLMapElement.areas
Josh-Cena Jul 13, 2024
919fcdf
Update page
Josh-Cena Jul 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions files/en-us/web/api/htmlmapelement/areas/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
---
title: "HTMLMapElement: areas property"
short-title: areas
slug: Web/API/HTMLMapElement/areas
page-type: web-api-instance-property
browser-compat: api.HTMLMapElement.areas
---

{{ApiRef("HTML DOM")}}

The **`areas`** read-only property of the {{domxref("HTMLMapElement")}} elements returns a collection of {{HTMLElement("area")}} elements associated with the {{HTMLElement("map")}} element.

Two successive calls to this property will return the same object.

## Value

A {{domxref("HTMLCollection")}} object of {{HTMLElement("area")}} elements.
ShubhamOulkar marked this conversation as resolved.
Show resolved Hide resolved

## Example

```html
<map name="image-map">
<a href="www.link1_example.com">link 1</a>
<area
alt="left arrow"
shape="circle"
coords="50,50,35"
href="www.left_example.com"
target="_top" />
<a href="www.link2_example.com">link 2</a>
<area
alt="right arrow"
shape="circle"
coords="150,50,35"
href="www.right_example.com"
target="_top" />
</map>
<img
usemap="#image-map"
src="left-right-arrow.png"
alt="left right arrow image" />
```

```js
const mapElement = document.getElementsByName("image-map")[0];
// Anchor elements are filtered out from HTMLCollection
console.log(mapElement.areas); // Output: HTMLCollection(2) [area, area]

const mapElementAreas = mapElement.areas;
// Iterate over each area element and change target value to _blank
[...mapElementAreas].forEach((area) => (area.target = "_blank"));
console.log(mapElementAreas[0]);
// click on left and right arrows, it will open a new tab.
ShubhamOulkar marked this conversation as resolved.
Show resolved Hide resolved
```

## Results

{{EmbedLiveSample("Example",100,100)}}

## Specifications

{{Specifications}}

## Browser compatibility

{{Compat}}

## See also

- {{domxref("HTMLAreaElement")}}
- {{domxref("HTMLImageElement.useMap")}}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading