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.

Images that create maps are inserted into the page using elements img 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 map which you are about to see later, preceded by a # or $ symbol. 

Element map actually create a map for the image and usually follow the element directly img . It acts as a container for the element which actually defines clickable hotspots. Element map carries only one attribute, name attribute, which is the map identifier. This is how the element img 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 : img src="images/usemap.gif" alt="HTML Map" usemap="#tutorials" border="0"    Using JavaScript Image Map : img src="images/usemap.gif" alt="HTML Map" usemap="#tutorials" border="0"   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

Update 25 May 2019
Category

System

Mac OS X

Hardware

Game

Tech info

Technology

Science

Life

Application

Electric

Program

Mobile