Image Map in JavaScript

You can use JavaScript to create Image map at Client-Side. Image maps are activated by the usemap attribute for the tag and are defined by special extension tags and.

You can use JavaScript to create an image map on the client-side. Image maps are enabled by the usemap attribute for the tag Picture 1 of Image Map in JavaScript Picture 1 Image Map in JavaScript download this picture HERE and is defined by special extension tags and .

Images that create maps are inserted into the page using elements Picture 2 of Image Map in JavaScript Picture 2 Image Map in JavaScript download this picture HERE as usual, except that it carries an additional attribute called usemap . The value of the usemap attribute is the name attribute value on the element which you are about to see later, preceded by a # or $ symbol.

Element actually create a map for the image and usually follow the element directly Picture 3 of Image Map in JavaScript Picture 3 Image Map in JavaScript download this picture HERE . It acts as a container for the element which actually defines clickable hotspots. Element carries only one attribute, name attribute, which is the map identifier. This is how the element Picture 4 of Image Map in JavaScript Picture 4 Image Map in JavaScript download this picture HERE know the element Which to use.

The element determines the shape and coordinates that define the limit (boundary) of a clickable hotpot.

The following code connects Image maps and JavaScript to create a message in the text box when moving the mouse over different parts of the image.

  Using JavaScript Image Map HTML Map   Using JavaScript Image Map HTML Map 
Perl Tutorial
HTML Tutorial
PHP Tutorial

Result

Follow the above method to see the results

According to Tutorialspoint

Last lesson: Debug in JavaScript

Next article: Browser compatibility in JavaScript

Thanks for reading the post

Image Map in JavaScript

Please share this article to your friends
« Browser compatibility in JavaScript
Debug in JavaScript »