ページに 40 個以上のボックスを表示します。
<div id="primary">
<div class="box" style="background:....">
<a href="" style="color:....">box1</a>
</div>
<div class="box" style="background:....">
<a href="" style="color:....">box2</a>
</div>
....
</div>
ご覧のとおり、背景色とテキスト色を設定しています。ホバーすると、色を交換したい:
$(".box").each( function () {
$(this).data('baseColor',$(this).css('background-color'));
$(this).find('a').data('fontColor',$(this).css('color'));
$(this).hover(function() {
$(this).animate({ backgroundColor:
$(this).data('fontColor') }, 500);
},function() {
$(this).animate({ backgroundColor:
$(this).data('baseColor') }, 1000);
});
});
背景色のアニメーションは機能しますが、要素のフォントの色を変更できません。何か案は?