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
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"
Result
Follow the above method to see the results
According to Tutorialspoint
Last lesson: Debug in JavaScript
Next article: Browser compatibility in JavaScript
You should read it
- Syntax of JavaScript
- What is JavaScript? Can the Internet exist without JavaScript?
- Introduction to 2D Array - 2-dimensional array in JavaScript
- What is Currying in Javascript? How to use Currying in JavaScript
- Things to know about 'this' in JavaScript
- Udemy's top 5 JavaScript courses
- Top site with many good JavaScript exercises to practice
- What is JavaScript?
- ! = and! == What is the difference in JavaScript?
- Learn about ES6 in Javascript
- Summary of JavaScript exercises with sample code
- JavaScript location in HTML File