How does the order of selectors depend on? The transition does not work if you put the transition class first https://jsfiddle.net/7u5z943r/ What is the difference? After all, the browser remembers the entire stream entirely.
$(document).ready(function(){ $('div').click(function(){ $('.q').toggleClass('q1'); }); }); .q1{ background: red; } .q{ width: 200px; height: 200px; background: black; transition: all 1s; } <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="q"></div>