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 - ![]() |
? At times, we must verify that the element does have the class 'className' ( Any specific name ). It is included the method of the class List entity. It can be used to determine whether an element has a particular class name. The single method...
3 min read
A parent node in JavaScript may have one or more child elements in JavaScript. Now how to fetch those child elements of a node in JavaScript is the question. In this section, we will discuss and look at how we can get child elements of a...
3 min read
The Factory Function is related to the constructor function or class functions. However, it produces and returns an object without requiring a new one. Factory Functions in JavaScript are identical to constructorfunctions. However, they don't require the 'this' keyword for inner values or the 'new' keyword...
3 min read
In this tutorial, we will see the aspects of limitations and functions related to the hasOwnProperty() method in JavaScript. We will also learn about its implementations and usage in the sections. Introduction In JavaScript, the hasOwnProperty() method is defined as a property to ensure whether the object...
5 min read
To get information from a server, utilize JavaScript's get() method. Any sort of API that returns data in JSON or XML can be requested. The URL to request is the only parameter needed for the Fetch () method, which also returns a promise. Send a Request...
6 min read
? Factorial of number is the product of all positive descending integers. Factorial of n is denoted by n!. For example - 4! = 4 * 3 * 2 * 1 = 24 5! = 5 * 4 * 3 * 2 * 1 = 120 Here, 4! is...
3 min read
Introduction: JavaScript is a widely used programming language, and it provides several built-in methods to manipulate strings. Two of the most commonly used methods for searching a string for a specific character or substring are indexOf() and search(). Although these two methods might appear similar in...
3 min read
In this article, we will understand the Filterable Gallery Using Filterizr javascript library. Filterable Gallery is a customizable component that is used to display collection of images, videos or other media with filtering, sorting, and searching function. Following are the examples of Filterable Gallery Using Filterizr...
7 min read
? A dynamic table is one whose number of rows varies based on the input it receives during runtime. Some websites or online programs, such as business websites, require the dynamic creation of a table while adding data or information. It can be done because JavaScript...
3 min read
The javascript sessionStorage object is a property of the window object that all modern browsers have. The protocol, hostname, and port of the page are linked to any information in sessionStorage. Each window has its session storage. The javascript sessionStorage is a procedure that aids...
6 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