Jquery width detection
Jquery width detection
Out of context: Reply #8
- Started
- Last post
- 10 Responses
- colossalhead0
Instead of calling changeMargin() immediately, try adding a callback to your animate effect. (see http://api.jquery.com/animate/)
In the callback function (which is executed when the animation is completed) update your coltotal value and then execute the changeMargin function. Basically something like this:
$(this).stop( true, true ).animate({width: "180px"},200, function() {
// Animation complete.
col1 = $(".col1").outerWidth();
col2 = $(".col2").outerWidth();
colTotal = col1 + col2;
$(".col3").text(colTotal);
changeMargin();
});