リンクがあります:
<a href="#">
Some text
<span style="width: 50px; height: 50px; background: url(image.png); overflow: hidden; opacity: 0;"></span>
</a>
<span>
そして、リンクがホバーされたときに、アニメーションで不透明度を変更したいと考えています。
どうすればいいですか?
別の可能な解決策:
$("a span").hover(function(){
$(this).stop().animate({"opacity": 1});
},function(){
$(this).stop().animate({"opacity": 0});
});
フェードアウト() を使用すると、スパンが折りたたまれます。
編集
これははるかに優れています:
$('a:has(span)').hover(function() {
$('span', this).stop().animate({"opacity": 1});
},function() {
$('span', this).stop().animate({"opacity": 0});
});
このような:
$('a:has(span)').hover(
function() { $('span', this).fadeIn(); },
function() { $('span', this).fadeOut(); }
);