Hi... jQuery beginner here.
Here is what I'm working on. I have an area map with 10 hotspots on it. Hover over each of the hotspots and it shifts the background of the div (id=dialpad) to display other data (in a sprite).
The code I have currently works, but I have a separate function for each hotspot ID.
Ex:
$('#dial1')
// On mouse over, move the background on hover
.mouseover(function() {
$('#dialpad').css('backgroundPosition', '0 -120px');
})
// On mouse out, move the background back
.mouseout(function() {
$('#dialpad').css('backgroundPosition', '0 0');
})
$('#dial2')
// On mouse over, move the background on hover
.mouseover(function() {
$('#dialpad').css('backgroundPosition', '0 -240px');
})
// On mouse out, move the background back
.mouseout(function() {
$('#dialpad').css('backgroundPosition', '0 0');
});
...
What I want to do is to consolidate that code into a single function where I simply pass the vertical offset figure from each area ID.
Can someone assist?