Enhancing images by creating clickable sections in a more organized and efficient manner

Are there any other methods to make parts of an image clickable in a more organized way, aside from using the coordinates method or directly embedding images from Photoshop?


<script>
new el_teacher = ["candice","john"];
$(".teacher1").mouseenter(function(){
$(#textbox").show(el_teacher[0]);
});
$(".teacher2").mouseenter(function(){
$(#textbox").show(el_teacher[1]);
});
$("*").mouseleave(function(){
$(#textbox").hide();
});
</script>

<img src="ok.jpg" usemap="#image1">
<map name="image1">
<area shape="poly"    coords="123,41,131,51,130,13,105,13,123,41,131,51,130,13,105,13,123,41,131,51,130,13,105,13,123,41,131,51,130,13,105,13,123,41,131,51,130,13,105,13,123,41,131,51,130,13,105,13,123,41,131,51,130,13,105,13" class="teacher1">
 <area shape="poly"      coords="13,41,141,455,677,13,213,313,133,99,555,99,333,222,211,105,13,123,41,131,51,130,13,105,13,123,41,131,51,130,13,105,13" class="teacher2">

 <!-- Sorry i do not have my codes with me right now but this is roughly the senario.  -->
 <!-- @jycr753 i want the user to change the position of the click and the image also. -->
 <!-- I am looking for jquery or javascript that can eliminate or shorten the coordinates so  that the user can edit the information themselves easily -->

Answer №1

One creative way to add interactivity to an image is by using it as a background-image for a div element. This allows you to position links or other interactive elements within the image. Here's an example:

Example HTML:

<div id="myImage">
    <a id="myImage_zone1" href="http://google.com"></a>
    <a id="myImage_zone2" href="http://aol.com"></a>
    <a id="myImage_zone3" href="http://yahoo.com"></a>
</div>

Example CSS:

#myImage {
    background-image: url(http://farm9.staticflickr.com/8370/8366240991_45a728b522_z.jpg);
    width: 640px;
    height: 457px;
    position:relative;
}
#myImage a {
    border:1px solid #fff;
    width:50px;
    height:50px;
    display:block;
    position:absolute;
    background-color:rgba(255,255,255,0.1);
}
#myImage a:hover {
    background-color:rgba(255,255,255,0.3);
}
#myImage_zone1{
    top:350px;
    left:350px;
}
#myImage_zone2{
    top:150px;
    left:200px;
}
#myImage_zone3{
    top:280px;
    left:100px;
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Submitting a form and obtaining results without relying on jQuery

Finding information on how to accomplish this task without using jQuery has proven to be a challenge. It seems like everyone is pushing for jQuery for even the simplest tasks nowadays. Despite avoiding unnecessary use of jQuery in creating a rich experienc ...

Dynamic class/interface in Typescript (using Angular)

Is there a way to achieve intellisense for an object created with a dynamic class by passing parameters? Here is the code snippet: Main: let ita: any = new DynamicClass('ITA'); let deu: any = new DynamicClass('DEU'); The DynamicClass ...

Heroku-hosted application experiencing issues with loading website content

I have been working on a nodejs application that serves a web page using express and also functions as a discord bot. The app runs smoothly on localhost with both the web page and discord functionalities working correctly. However, when I deploy it to Hero ...

What benefits does utilizing unordered lists provide in navigation bars?

Throughout my research, I have come across numerous tutorials detailing the process of creating a navigation bar. They often begin by adding an unordered list and then proceed to remove the default styling such as bullet points and margins from both the ...

Prevent the utilization of <span> tags for line breaks to

When resizing my window to a smaller size, I encountered some unsightly spans that cut into new lines. To demonstrate this issue, I intentionally set the width:20px;. Can this problem be avoided? <link href="https://maxcdn.bootstrapcdn.com/bootstrap/ ...

Knockoutjs is not binding with newly added HTML elements by Ajax after calling ko.applyBindings

Recently, I encountered an issue with an ASP.NET MVC 4 View utilizing KnockoutJs (version 2.3.0). While the page loads smoothly and existing elements with the data-bind attribute function as expected, adding HTML via Ajax containing a data-bind for an obse ...

What is the best way to send an HTTP request in AngularJS to receive data in JSON format?

I am trying to create an AngularJS app that can send HTTP requests for JSON data. I have written the code in my index.html file to request JSON data using AngularJS, but for some reason, the JSON data is not being printed. When I check the console in Fire ...

How do I preserve data within $scope upon switching views using ng-include?

Can you please take a look at this jsFiddle? http://jsfiddle.net/mystikacid/b7hqcdfk/4/ This is the template code: <div ng-app="myApp"> <div ng-controller="dataCtrl"> <div>Data : {{data}} (Value outside views)</div> < ...

Choose the div without a class

I currently have several divs displayed on my website. <div class="slide bx-clone"></div> <div class="slide"></div> <div class="slide"></div> <div class="slide bx-clone"></div> <div class="slide bx-clone" ...

Is it possible to convert MUI components into strings on the client side?

I have incorporated the Material UI (MUI) library into my React application and am currently attempting to display certain components as PDF files directly in the browser. The approach I am taking involves: Creating a React element Rendering the React el ...

Utilize the grid system from Bootstrap to style HTML div elements

I am working on my angular application and need help with styling items in a Bootstrap grid based on the number of elements in an array. Here's what I'm looking to achieve: If there are 5 items in the array, I want to display the first two items ...

"Searching for existing data in MongoDB upon click event from the client side: A step-by-step guide

I have developed an express app that allows users to search for movies and add them to lists. If a movie is already added to the list, I want to show 'Already added' instead of 'Added to list'. How can I achieve this functionality from ...

Choosing elements in HTML using jQuery from an Ajax GET response

As a programming student, I am currently working on developing a basic website using HTML, JavaScript, and jQuery for the front-end, while utilizing node.js and Express frameworks for the back-end. In my project, I have used Ajax to retrieve data and then ...

What is causing the issue of the div not being removed from the label renderer in three.js

Hello, I've been trying to solve this issue for the third time now without much success. The problem I'm facing is related to creating a div at runtime and then attempting to remove it after clicking on it. Although I've tried removing the d ...

ERROR: Module 'jquery' not found in path 'C:....' when using Gulp and Browserify

Encountering an error: Error: Module 'jquery' not found in path 'F:...\newstyle\assets\lib\helper\html\img\js' at C:\Users...\AppData\Roaming\npm\node_modules&bs ...

What exactly is the purpose of utilizing node js and can someone explain to me what constitutes a

After mastering HTML and CSS, I've started diving into JavaScript. However, I'm curious about Node.js. What exactly is it, why do I need it, and can you explain what a framework is in general? Sorry if these questions sound silly! ...

displaying the download status of a file during the download process with PHP and jquery

Exploring the creation of a unique download manager with PHP and jQuery. In search of a script that enables file downloads with visible progress tracking. The attempted implementation has not yielded the desired results: jQuery function init ...

Combining multiple API requests using NodeJS

I'm currently experimenting with SteamAPI to enhance my understanding of NodeJS. My aim is to retrieve game information after making an initial request to obtain the player's profile and storing the game IDs in an array. However, I am facing a ch ...

Looking for a way to add interactivity to this canvas rectangle?

ctx.fillStyle = "#9b958c"; ctx.fillRect(sampleRectX, sampleRectY, sampleRectW, sampleRectH); ctx.fillStyle = "#fff"; ctx.fillText("Click here to play again.", sampleTextX, sampleTextY); This clickable rectangle has been giving me some trouble. While I fou ...

Efficiently repositioning Kendo Mobile Buttongroup to a new row as needed

In my current project, there is a specific requirement to display three button groups in a row. If there are more than three buttons, they should move to the next row dynamically as the data will be fetched from the server. For reference, below is a sampl ...