この問題に関する他の質問と回答を読みましたが、うまくいきませんでした。何かが欠けているか、私の例が少し異なっている可能性があります。わかりません。とにかく、テキストとリンクを含む div があり、ユーザーがこの最初の div にカーソルを合わせたときに新しい div を作成したいと思います。問題は、最初の div を超えると、マウスで最初の div を離れなくても、2 番目の div が連続してフェードインおよびフェードアウトすることです。
HTMLコードは次のとおりです。
<div id="content">
<h1>Portfolio</h1>
<div id="web">
<p>Web apps</p>
<a href="#">
First link
</a>
</div>
<div id="commentweb">
<p>The text that I want to show</p>
</div>
</div>
これはjQueryです:
$(document).ready(function() {
$("#web").click(function(){
window.location=$(this).find("a").attr("href");
return false;
});
$("#commentweb").hide();
$("#web").hover(
function () {
$(this).children("a").children("img").attr("src","2.png");
$(this).css("background-color","#ecf5fb");
$(this).css( 'cursor', 'pointer' );
$(this).css('border','1px solid #378ac4');
$(this).children("p").css("opacity","1.0");
$('#commentweb').stop(true, true).fadeIn();
},
function () {
$(this).children("a").children("img").attr("src","1.png");
$(this).children("p").css("opacity","0.5");
$(this).css("background-color","#e8e3e3");
$(this).css('border','1px solid grey');
$('#commentweb').stop(true, true).fadeOut();
}
);
});
#web を超えたときにフェードイン アニメーションを開始し、その div を離れるときにフェードアウト アニメーションをちらつきなく (つまり、一定のフェードインとフェードアウト) 開始するにはどうすればよいですか?
問題を示すためにフィドルを追加しました: http://jsfiddle.net/mMB3F/ 基本的に、テキストにカーソルを合わせると発生します。