I'm changing an image on hover using JS, and would like to add a fading animation to it. I've tried added .fadeToggle(), but nothing is working correctly.
$("document").ready(function(){
$(".logo_container").mouseenter(function(){
$("#logo").attr('src',function(index, attr){
return attr.replace(".png", "-color.png");
});
});
$(".logo_container").mouseleave(function(){
$("#logo").attr('src',function(index, attr){
return attr.replace("-color.png",".png");
});
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="logo_container">
<img src="https://ironhorseclub.wpengine.com/wp-content/uploads/2018/05/logo2-sm.png" alt="Wordpress Install" id="logo" data-height-percentage="100">
</div>