If I have to following HTML which is a image of a map. The map is divided into colour areas. My goal is if the cursor is over an area of the image, to swap the image.
<div id="map" class="mouse-click"><img class="image-swap" src="images/map.png" /></div>
I can find the X Y Coords with
$('#map').mousemove(function(e){
var x = e.clientX - this.offsetLeft;
var y = e.clientY - this.offsetTop;
$('#map-xy').html("X: " + x + " Y: " + y);
});
How do I add a click event to swap the img if the cursor is between a set of coordinates.
Any help is appreciated.
Where
xMin
,xMin
,yMax
, andyMin
describe the boundaries of the target area.