0
<DIV id=gallery2>
  <DIV class=center_content>
    <A id=example2 class=photo-link title=567 href="http://www.hdwallpapersarena.com/wp-content/uploads/2012/06/Desktop-wallpaper-Free-honey-bee1.jpg" rel=group1 smoothbox?>
      <IMG id=mygal class=mygalclass src="http://www.hdwallpapersarena.com/wp-content/uploads/2012/06/Desktop-wallpaper-Free-honey-bee1.jpg" width=132 height=137>
    </A>
  </DIV>
</DIV>

ミツバチの画像にカーソルを合わせるspanとリンクが表示されますが、選択して消えると、画像のイベントがspan原因だと思います。mouseleave

これがデモですhttp://jsfiddle.net/sbYG4/13/

DivImageおよびSpanを同じonmouseenterおよびに関連付けるにはどうすればよいmouseleaveですか?

4

2 に答える 2

0

div idを使用してすべてを1つにまとめると、そのdivに入るたびに、すべてのスパンimgなどが有効になり、タグを使用していて、cssanchorにその指定がないため、プラスに設定すると、タグを次のように使用できます。スペースを取り、いつ発生するかを実行できるようにするためtext-decorationnoneanchordisplay:inline-blockonmouseenteronmouseleave

これを使用して動作します(複数の画像に対して再度更新されます)

$(".photo-link").on({

    mouseenter: function () {

 $(this).find('span').fadeIn('slow');
    },
    mouseleave: function () {
 $(this).find('span').fadeOut('slow');
    }
});

プラスすでにそれを持っていたのでそれを削除display:noneしましたA.deletespan

于 2012-08-29T15:56:10.660 に答える
0

あなたの最初の質問に答えて:私たちはイベントのコードを持っていないので、私たちは本当に言うことができません。

2番目の質問に答えて、3つすべてに同じクラスを与え、onmouseenterandonmouseleaveハンドラーをクラスにアタッチします。

jQueryを使用している場合は、次のようになります。

$('.theClassYouGaveThem').bind("mouseenter", function(){/*Code here */ });

$('.theClassYouGaveThem').bind("mouseleave", function(){/*Code here */ });

または、両方を実行したい場合は、

$('.theClassYouGaveThem').bind("mouseenter mouseleave", function(){/*Code here */ });
于 2012-08-29T15:53:17.103 に答える