I trying to animate img
change from a div and I tried to use jquery to do so as it seems the cleanest way. I tried to use this answer but without any success. Where I am wrong with my approach?
HTML:
<div class="jumbotron text-center" id="main-jum">
<img id="jum-img" src = "https://im.whatshot.in/img/2017/Oct/churrosweb-1509092812.jpg">
</div>
<div class="container-fluid text-center d-none d-md-block" id="jum-btns">
<div id="jum-btn" class="btn-group " role="group" aria-label="Basic example">
<button type="button" id="btn-left" class="btn btn-secondary jum-btn" onclick="changeColor();">Left</button>
<button type="button" id="btn-middle" class="btn btn-secondary jum-btn" onclick="changeColor();">Middle</button>
<button type="button" id="btn-right" class="btn btn-secondary jum-btn" onclick="changeColor();">Right</button>
</div>
</div>
<script type="text/javascript">
$(document).ready(function(){
$('#btn-left').click(function() {
$('#jum-img').fadeOut(500, function() {
$('#jum-img').attr("src","https://truffle-assets.imgix.net/pxqrocxwsjcc_5pcvIMJdpmi8COGYQ0kua6_churros-with-dulce-de-leche_landscapeThumbnail_en-US.jpeg");
$('#jum-img').fadeIn(500);
});
});
});
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>