Why does the transition I set up not animate? I would expect that since the class animate
is being removed and then re-added to the element then it would re-animate once switching tabs.
https://jsfiddle.net/jstn/Lt6qfv7s/
Thank you,
Justin
$('button').on('click', function () {
var tab = $(this).attr('data-target');
$('.tab').removeClass('active');
$(tab).toggleClass('active');
$('.content').removeClass('animate');
$(tab).find('.content').toggleClass('animate');
});
.tab:not(.active) { display: none; }
.content { transition: 3s all ease-out; }
.content.animate { opacity: .3; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button data-target=".tab-1">Tab #1</button>
<button data-target=".tab-2">Tab #2</button>
<div class="tab tab-1">
<div class="content">This is Tab #1</div>
</div>
<div class="tab tab-2">
<div class="content">This is Tab #2</div>
</div>