How to create an image map in JavaScript?17 Mar 2025 | 3 min read JavaScript can be used to create a client-side image map. An image map is an image on the webpage that has multiple links to other pages. These links are called hotspots. An image map is used to navigate different links to other pages or on the same web page. In an image map, an image can be divided into different sections. We can include links to each section, and after clicking a section, it will open the corresponding link. The sections can be divided into different shapes, such as circle, rectangle, or polygon. For creating a rectangular image map, we require two different coordinates that are top right and bottom left. Similarly, for creating a pentagon image map, we require five coordinates. Images map provides a way to link various sections of the image without require creating image files. The usemap attribute is used in the <img> tag to define the map description into that image. This attribute calls the map description applied to the specific image. Every image map has a unique map so, we have to use the name attribute in the MAP element. There is another tag called <area> tag, which defines the coordinates and shapes of each section. We can use the events such as onclick, ondblclick, onmouseover, onmouseout, onblur, etc. with the <area> tag. The piece of code for defining the image map is given as follows. SyntaxNow, let's see some illustrations of using the image map to understand it more clearly. ExampleIn this example, there is an image that we are using for creating an image map. We are dividing the image into two sections in the rectangular and circular shape. The first section is the top area of the image, and the second section is the middle area of the image. Test it NowOutput After the execution of the above code, the output will be - ![]() On clicking the top area, the output will be - ![]() On clicking the middle area, the output will be - ![]() Example2Here, we are passing the images in the href attribute of the <area> tag. It means that when we click on the sections, the corresponding image will be displayed. The image is divided into two sections. The first section is the top area of the image, and the second section is the middle area of the image. On clicking the corresponding sections, first the name is displayed of the linked image in the given textfield, and then the image will show. Output After the execution of the above code, the output will be - ![]() On clicking the top area, the output will be - ![]() On clicking the middle area, the output will be - ![]() |
Javascript getModifierState() KeyboardEvent uses to know which keypresses are on the keyboard. The event returns true if modifiers keys are pressed or clicked off the keyboard. We can use the pressed, clicked key, and the keyboard event activates the function. Syntax The syntax uses the javascript tag...
3 min read
What is Lodash? Lodash is a JavaScript library that has a lot of inbuilt functions, and it provides utility and more functionality to the developers. It is built upon the underscore.js library of JavaScript. Lodash._chain() Method This method is used to wrap the value which we get from...
3 min read
A collection of properties is stored in an object. In an object, there is an association of a name, also called a key and a value combined with called key and value pairs. But then, external dependency is not required by it when it refers to...
2 min read
? JavaScript is a client-side scripting language and one of the most efficient, commonly used scripting languages. The term client-side scripting language means that it runs at the client-side( or on the client machine) inside the web-browsers, but one important thing to remember is that client's...
3 min read
In this article, we are going to discuss currying in JavaScript. Here, we will see how currying works and how it will be useful for software developers. We will also see the conversion of an existing function into the curried version. So, this article is...
4 min read
What is an URL? A URL is another name for a web address. For instance, a word-based URL is TpointTech.com. A URL can also be created using an IP address (ex. 192.168.2.24). Most consumers provide the name's address when conducting an online search because names are...
3 min read
The Node Package Manager is known as npm. It serves as the Node JavaScript platform's package manager. The largest software registry in the world is referred to as Npm. Npm is a sharing and displaying tool used by open-source developers worldwide. Npm Parts Npm is made up of...
4 min read
We basically face some type of situation during programming in javascript in which we can create any function on the button click. For example, we have to examine some more functionality in the time of automation testing of a web page or a site. In...
3 min read
In this article, we will understand the how to create Presentation using JavaScript. A presentation is used to convey information. It separates your HTML content into several slides so that the visitors are able to navigate between these slides with certain operations such as mouse...
13 min read
JavaScript provides an efficient garbage collection for memory management. JavaScript automatically supports memory management and is invisible to us. When we create new objects, functions, primitives and variables, all these programming elements take memory. How does JavaScript manage these elements and cleans them? In this section,...
8 min read
We request you to subscribe our newsletter for upcoming updates.
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India