2 つdivの があり、2 番目divは 1 番目と同じ幅でなければならないとします。最初のものを取得し、プロパティでwidth2番目を設定すると、最初のものはわかっているため、機能します。しかし、それは知られていません。最初の実行が完了するまで待たなければなりません。div.csswidthdiv.animate.animate
#a
{
background-color: green;
}
#b
{
background-color: red;
}
<span id="a">aaa aa a a a a a aa</span>
<br />
<span id="b">bbb</span>
$(document).ready(function()
{
// this works, but I dont want this
$('#b').width ($('#a').width());
// and this WONT work, because widht of #a is not yet calculated
$('#b').animate({
'width' : $('#a').width()
}, 1500);
}