I have a div with css style property.
I change the width of div using JQuery.then take the width , but it gives the old width.
http://jsfiddle.net/zbou654e/1/
<div id="box"></div>
#box{
background-color:red;
width:200px;
height:200px;
-webkit-transition-duration: 0.2s;
-moz-transition-duration: 0.2s;
-ms-transition-duration: 0.2s;
-o-transition-duration: 0.2s;
transition-duration: 0.2s;
-webkit-transition-property: height, width;
-moz-transition-property: height, width;
-ms-transition-property: height, width;
-o-transition-property: height, width;
transition-property: height, width;
}
$(document).ready(function(){
$('#box').css("width","400px") ;
console.log($('#box').width());
});
it gives width as 200.Actual value is 400
I think because of css transition property..How to solve it?
Following snipped help you or you can check FiddleJS
$(document).ready(function () {
$('#box').css("width", "400px");
$("#box").on('transitionend webkitTransitionEnd oTransitionEnd otransitionend MSTransitionEnd', function () {
console.log($('#box').width());
});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With