我在JS和JQuery真正的新,我未能在選擇動畫一個元素選擇一個元件附近的第一H2,這是我的HTML與jQuery
<div class="box-product">
<h2>Light</h2>
<figure>
<img src="img/boxes/light.jpg" alt="Pepper Box Light" title="Pepper Box Light" />
<figcaption>
Versão light, porém igualmente apimentada da nossa PepperBox, para quem quer se divertir com seu amor</figcaption>
</figure>
</div><!-- box-product -->
我試圖選擇該h2
當用戶將鼠標懸停在figure
,所以這是我最好的猜測:
$('.box-product figure').hover(function() {
$('.box-product').closest('h2').animate({color: 'f00'}, 'slow')
}, function() {
$('.box-product').closest('h2').animate({color: 'inherit'}, 'slow')
});
但沒有任何反應,所以,我需要一些幫助。
謝謝!
感謝您的快速回答,這工作,但就像我說過那裏,顏色設置爲'F00',沒有正確它'#F00'什麼也沒有發生。 – 2012-08-03 05:18:25
@EduardoRuiz不客氣,是的,這是一個錯字。 – undefined 2012-08-03 05:20:37