I have three unordered list each surrounded by a container div (An example is showed below, pretty much the same for all three divs). Each list is a link, and once a user hover over the link, the text in a paragraph should change. I've managed to do that, but on hover, the text of the paragraph of all three div's changes. I know why this is happening but not sure how to modify my code.
div ul li span {
display: none;
}
$(document).ready(function () {
$("div ul li a").hover(function() {
$(this).parent().addClass('current').siblings().removeClass('current');
$('.highlight').html($('.current a span').html());
});
});
<div>
<ul>
<li><a href="#"><img src="images/test-1.gif" alt="#"></img><span>Test</span></a></li>
<li><a href="#"><img src="images/test-2.gif" alt="#"></img><span>Testing</span></a></li>
<li><a href="#"><img src="images/test-3.gif" alt="#"></img><span>More Testing!!!</span></a></li>
<li class="last"><a href="#"><img src="images/test-4.gif" alt="#"></img><span>Even More More Testing!!!</span></a></li>
</ul>
<p class="highlight">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus in eros tortor.</p>
</div>