you can prevent on mouse out function when img has not class selected like
//on mouseout
function () {
if (!$(this).hasClass("selected"))
{
$(this).stop().animate({
opacity: 0
});
}
}
Means you have to check in mouseover/out function that: your images has already clicked or not?
- Onmouseover:if not already clicked(Selected) then add overlay
- Onmouseout: if not already clicked(Selected) then remove overlay