2

次のスクリプトを使用していますが、プレースホルダー div があります。マウスオーバーすると、div 再生ボタンがプレースホルダーの上に来るはずです。

3 つのプレースホルダーが連続しています。特定のプレースホルダーにマウスを合わせると、すべての再生ボタンが表示されます。私が必要とするのは、プレースホルダーをマウスオーバーすると、その再生画像のみが表示されることです。

私の質問を理解していただければ幸いです。誰でも私がこれを行うのを手伝ってもらえますか?

jQuery.noConflict();
       jQuery(function(){
        jQuery('.placeholder').mouseover(function(){
               jQuery('.play').show('show');
        });
        jQuery('.placeholder').mouseleave(function(){
               jQuery('.play').hide('hide');
        });
      });

HTML:

 <div class="placeholder item"><div class="play"><img src="images/play_ico.jpg"></div></div>
 <div class="placeholder item"><div class="play"><img src="images/play_ico.jpg"></div></div>
 <div class="placeholder item"><div class="play"><img src="images/play_ico.jpg"></div></div>

CSS:

.placeholder{
    width:120px;
    float:left;
    background:#ccc;
    height:67px;
    position:relative;
}

.play{
    width:120px;
    height:67px;
    position:absolute;
    top:0;
    left:0;
    display:none;
    background:#000;
    opacity:0.4;
filter:alpha(opacity=40);
}
4

3 に答える 3

5

次のことを試してください。

    jQuery('.placeholder').mouseenter(function(){
           jQuery(this).find('.play').show();
    });
    jQuery('.placeholder').mouseleave(function(){
           jQuery(this).find('.play').hide();
    });

hover別の方法として、次の方法を使用できます。

    jQuery('.placeholder').hover(function() {
           jQuery(this).find('.play').show();
    }, function() {
           jQuery(this).find('.play').hide();
    })
于 2012-07-27T20:13:30.163 に答える
2

これを正しく行っていると確信していますか?また、本当に noConflict を使用する必要がありますか?

jQuery(function(){
    jQuery('.placeholder').on({
        mouseenter: function(){
           jQuery('.play', this).show('slow');
        },
        mouseleave: function() {
           jQuery('.play', this).hide('slow');
        }
    });
});

あるいは単に

jQuery('.placeholder').on('mouseenter mouseleave', function() {
    jQuery('.play', this).toggle();
});
于 2012-07-27T20:15:15.547 に答える
0

頭のてっぺんから、「表示」と「非表示」は、それらの名前でカスタムアニメーションを使用していない限り、表示機能と非表示機能に渡す有効なパラメーターだとは思いませんか?

試してみてください

jQuery('.play').show();

jQuery('.play').hide();

それらをアニメーション化したくない場合は、使用します

jQuery('.play').show('slow');

jQuery('.play').hide('slow');

または同等のもの:)

http://api.jquery.com/show/

于 2012-07-27T20:14:16.003 に答える