Good, I need to know how to make this Java Script code more optimized, it works for me so far. I have Divs with class "item" and images inside. The only thing I do is change the attribute when they are in mouse over and out, but I need help to know how to make it optimal. Thank you. I have this HTML code:
<div class="item1">
<img id="im1" src="img/image1.png">
</div>
<div class="item2">
<img id="im2" src="img/image2.png">
</div>
<div class="item3">
<img id="im3" src="img/image3.png">
</div>
<div class="item4">
<img id="im4" src="img/image4.png">
</div>
And I have this Java Script code
$("#item1").mouseover(function(){
$('#im1').attr("src", "img/image1_over.png");
});
$("#item1").mouseout(function(){
$('#im1').attr("src", "img/image1.png");
});
$("#item2").mouseover(function(){
$('#im2').attr("src", "img/image2_over.png");
});
$("#item2").mouseout(function(){
$('#im2').attr("src", "img/image2.png");
});
$("#item3").mouseover(function(){
$('#im3').attr("src", "img/image3_over.png");
});
$("#item3").mouseout(function(){
$('#im3').attr("src", "img/image3.png");
});
$("#item4").mouseover(function(){
$('#im4').attr("src", "img/image4_over.png");
});
$("#item4").mouseout(function(){
$('#im4').attr("src", "img/image4.png");
});