2010-08-30 59 views
2

我正在爲我的網站使用Wordpress。我想要實現的是,如果我徘徊在特定的職位上,它應該顯示該職位的頭銜。但是現在它的作用是,如果我將鼠標懸停在一個帖子上,它會顯示所有帖子的標題。將鼠標懸停在特定帖子上應該只顯示該帖子的標題

代碼:

<?php if (have_posts()) : ?> 

     <?php while (have_posts()) : the_post(); ?> 

     <div class="post"> 
      <div> 

       <div class="post-header"><a href="<?php the_permalink() ?>"> 
       <?php if (p75HasThumbnail($post->ID)) { ?> 
        <img src="<?php echo p75GetThumbnail($post->ID, 200, 108); ?>" alt="<?php the_title(); ?>" width="200" height="108" /> 
       <?php } ?> 
       </a></div> 

     <div class="post-content" style="display:none;"> 
        <h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>  
       </div> 

       <div class="post-footer"> 
        <small> 
        In: <?php the_category(' | ') ?> 
        </small> 
       </div> 
      </div> 

     </div> 
     <!-- --> 


    <?php endwhile; ?> 


    <?php next_posts_link('<div class="post archiveTitle "><div>&larr; Older</div></div>') ?> 
    <?php previous_posts_link('<div class="post archiveTitle "><div>Newer &rarr;</div></div>') ?> 


    <?php else : ?> 

    <div class="post"> 
     <div> 
      <h1>Not Found</h1> 
      <p>Sorry, but you are looking for something that isn't here.</p> 
     </div> 
    </div> 

    <?php endif; ?> 

JS:

<script type="text/javascript" charset="utf-8"> 
    $(document).ready(function() { 
     $('.post-header').hover(function(){ 
      $('.post-content').show(); 
     }, function(){ 
      $('.post-content').hide();  
     }); 
    }); 
    </script> 

回答

3

我不知道,如果是這樣,你想達到什麼:

$('.post-header').hover(function(){ 
    $('.post-content', $(this).parent()).show(); 
}, function(){ 
    $('.post-content').hide();  
}); 

現在只有交顯示當前懸停的帖子的內容。

+0

是的,謝謝! – input 2010-08-30 23:11:05