Javascript examples for DOM HTML Element:Area
The shape property sets or gets the value of the shape attribute of an area.
Set the shape property with the following Values
Value | Description |
---|---|
default | Sets the entire region |
rect | Defines a rectangular region |
circle | Defines a circular region |
poly | Defines a polygonal region |
A String, representing the shape type of the area
The following code shows how to Change the shape for a specific area in an image-map:
<!DOCTYPE html> <html> <body> <img src="http://java2s.com/resources/a.png" width="145" height="126" usemap="#myMap"> <map name="myMap"> <area id="myId" shape="circle" coords="125,60,10" alt="Venus" href="venus.htm"> </map>//from www . java 2s.c o m <button onclick="myFunction()">change the shape</button> <p id="demo"></p> <script> function myFunction() { document.getElementById("myId").shape = "default"; document.getElementById("demo").innerHTML = "The shape was changed from 'circle' to 'default'."; } </script> </body> </html>