I am switching from jQuery 2.0.3 to 2.1.0.
I noticed that in v2.1.0 the css transition
property is ignored when setting css properties directly
$('#someElement').css('width','100px');
In v2.0.3 , my element will maintain it's css
transition, whereas I lose that in v2.1.0.
I am wondering why this is treated differently, and how I can 'turn on' the transition effect.
With jQuery 2.0.3, the css transition
property takes effect
$(function() {
$('.myClass').css('width', '100px');
});
.myClass {
height: 50px;
width: 300px;
background-color: red;
transition: width 3s;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<div class="myClass"></div>
With jQuery 2.1.0, the css transition
property is ignored
$(function() {
$('.myClass').css('width', '100px');
});
.myClass {
height: 50px;
width: 300px;
background-color: red;
transition: width 3s;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<div class="myClass"></div>
Edit:
I am seeing this odd behavior in Chrome Version 47.0.2526.106 m
In Firefox 42.0, both animate properly
-webkit-transition: width 3s
to the class property. – Iguanodon