2012-01-21 69 views
0

Iam只是试图创建一个隐藏描述的产品目录。它需要显示用户何时悬停在上面。如何获得这项工作?jquery mouseover和mouseout

<script> 
    $("div.template_showcase").hover(function(){ 
      $("div.app_details").css('margin-top','-154px';); 
    },function(){ 

      $("div.app_details").css('margin-top','-8px';); 
     }); 
</script> 


<div class="template_showcase"> 
      <a href="#"><img src="<?php echo get_stylesheet_directory_uri() ?>/images/templates/review.png" /> 
      <div class="app_details"> 
      <span class="paratitle">Review</span> 
      <span class="para"> 
      Turn your jumbo in to a review site 
      </span> 
      <span class="addbutton">Add to Jumbo</span> 
      </div> 
      </a> 
</div> 

回答

0

你在css属性分配里面有多余的分号,这可能是你的代码被破坏的原因。只需使用show()hide()即可。虽然通常不会使用有用的负边距。

<script> 
    $("div.template_showcase").hover(function(){ 
      $("div.app_details").show(); 
     },function(){  
      $("div.app_details").hide(); 
     }); 
</script>