0

に画像と段落があるdivがあります。段落に表示したいタイトルをロールオーバーすると、このコードは他のサイトでは機能しましたが、何らかの理由でここでは機能しません。

誰かが私が間違っていることを教えてもらえますか

 $(document).ready(function() {

$('.post-band h2').hover(function(){
        $(".entry p",this).fadeTo("fast", 1);
          //$(".entry p",this).slideDown();
        },
    function(){
         $(".entry p",this).fadeTo("fast", 0);
        //  $(".entry p",this).slideUp();
                });

});

<div class="post-band" id="post-67">

 <h2>Dale Rodman</h2>
<div class="band-image">
<img width="300" height="250" src="http://localhost/wp-content/uploads/2012/02/dale1.jpg" class="attachment-post-thumbnail wp-post-image" alt="dale" title="dale" /></div>

 <div class="entry">
   <p>Dale has been passionate about music ever since he stopped being passionate about something else, when he puts his mind to something there is not stopping this machine, playing guitar since he was little his ability to absorb different styles has help to create a style like non other.</p>
<h3>Acoustic Guitar, Vocals</h3>
 </div>
    </div>
4

2 に答える 2

0

$(".entry p",this)ホバー関数では、セレクターを内部$('.post-band h2')( 内h2) で探します。.closest()おそらく、上昇して.find()から下降するために混合が必要です。

しかし、より良い答えを得るためにあなたのhtmlを投稿してください。

于 2012-02-11T17:47:44.790 に答える
0

考えられる解決策のフィドルは次のとおりです。http://jsfiddle.net/sDJDr/

私が使用した JavaScript は以下であり、上記の ori の意味でもあります。

$(document).ready(function() {

    $('.post-band h2').hover(function(){
        var $p = $(this).closest('div.post-band').find('p');
        $p.fadeTo("fast", 1);
        //$(".entry p",this).slideDown();
    },
    function(){
        var $p = $(this).closest('div.post-band').find('p');
        $p.fadeTo("fast", 0);
        //  $(".entry p",this).slideUp();
    });

});
于 2012-02-11T19:29:08.587 に答える