I'm a beginner in jQuery and I have this code snippet that displays a div when a specific link on a map is hovered over:
<div id="locationmap">
<a class="linkhide" id="link1" href="#">Occupier 1</a>
<a class="linkhide" id="link2" href="#">Occupier 2</a>
<a class="linkhide" id="link3" href="#">Occupier 3</a>
</div>
<div id="mapdetail">
<div class="hideme" id="local1" style="display:none;">
<p>Some content one</p>
</div>
<div class="hideme" id="local2" style="display:none;">
<p>Some content two</p>
</div>
<div class="hideme" id="local3" style="display:none;">
<p>Some content three</p>
</div>
</div>
<script type='text/javascript'>//<![CDATA[
$("#link1, #link2, #link3").mouseover(function() {
var num = $(this).attr('id').replace("link",'');
$("#local"+num).fadeIn(500);
});
$(".linkhide").mouseout(function() { $(".hideme").css('display','none'); });
//]]>
</script>
Is there a way to optimize the repeated .fadeIn(500) for each link?
Here's my JSfiddle: http://jsfiddle.net/karlgoldstraw/4NRY7/
Thanks.