My dilemma lies in applying CSS3 Transitions to elements by introducing a new class.
Markup
<div id="parent">
<div class="child">
</div>
</div>
CSS
.child {
background: blue;
-webkit-transition: background 4s;
-moz-transition: background 4s;
transition: background 4s;
}
.newChild {
background: red;
}
JavaScript/jQuery
$(".child").addClass("newChild");
My issue arises when I clone the .child
element before adding the new class, as the transitions take effect immediately instead of after 4 seconds
.
Feel free to explore this example.