Is it possible to use animate() to increase a div's width dynamically and display this in a variable?
I've tried several things, but the variable still displays the original width of the div (wich is zero) So it's not being updated.
HTML
<a href="#" id="button2">Add width</a>
<div id='content'></div>
<div id="msg"></div>
jQuery
$('#button2').click(function () {
$('#content').animate({
width: '+=40'
}, 500);
});
var width = $('#content').width();
$("#msg").html(width);
So I would like to know how I can accomplish this. Should I write a update function for the variable or is there a more simple way?