I have a map with a bunch of link images on top of it. They all have the same image, with different positions.
<div id="map" class="small-12 large-9 left">
<img src="a-map.jpg">
<a class="city1"><img class="large-12 small-8" src="fundita-mov.png"></a>
<a class="city2"><img class="large-12 small-8" src="fundita-mov.png"></a>
<a class="city3"><img class="large-12 small-8" src="fundita-mov.png"></a>
<a class="city4"><img class="large-12 small-8" src="fundita-mov.png"></a>
<a class="city5"><img class="large-12 small-8" src="fundita-mov.png"></a>
</div>
The css for them (you get the idea)
#map a{position:absolute;}
a.cityx{left: 35%;top: 26%;}
When you hover or click any of the image link, some info attached to that specific link becomes visible in a sidebar.
<div id="map-hover-result" class="small-12 large-3 left">
<ul>
<li id="city1" class="hidden">some info here</li>
<li id="city2" class="hidden">some info here</li>
<li id="city3" class="hidden">some info here</li>
<li id="city4" class="hidden">some info here</li>
<li id="city5" class="hidden">some info here</li>
</ul></div>
The way I handle the "hidden" class is like this. Is there any way I could optimize this?
<script> $("a.city1").hover(function(){$('#city1').toggleClass('hidden');});
$("a.city1").click(function(){$('#city1').toggleClass('hidden');});
$("a.city2").hover(function(){$('#city2').toggleClass('hidden');});
$("a.city2").click(function(){$('#city2').toggleClass('hidden');});
$("a.city3").hover(function(){$('#city3').toggleClass('hidden');});
$("a.city3").click(function(){$('#city3').toggleClass('hidden');});
$("a.city4").hover(function(){$('#city4').toggleClass('hidden');});
$("a.city4).click(function(){$('#city4').toggleClass('hidden');});
$("a.city5").hover(function(){$('#city5').toggleClass('hidden');});
$("a.city5").click(function(){$('#city5').toggleClass('hidden');});
</script>
a.cityXin your HTML ?Xis intended to denote a numeral in this case.