JQuery在悬停时显示隐藏类 [英] JQuery Show hide class on hover

查看:193
本文介绍了JQuery在悬停时显示隐藏类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对JQuery比较新,我想在鼠标悬停时显示一个菜单。

I am relatively new to JQuery and I would like to be able to show a menu on mouseover.

这里是html

<td class ="comment_div"> <?php echo("$comment_data['comment']); ?> <br/>  
   <span class="comment_actions"> Approve | Delete | Spam | Edit</span>  
</td>

然后JQuery

 $("comment_div").hover(
      function() { $(".comment_actions").show(); },
      function() { $(".comment_actions").hide(); }
 );

这个工作除了我拉多个注释,这只会显示在第一个div的菜单,无论什么评论是hoverd。我想让菜单显示只有当前的评论hoverd over。我想我需要使用$ this来使这个工作,但不知道如何。

This works exept for I'm pulling multiple comments out and this only will show the menu on the first div no matter what "comment" is hoverd. I would like to to have the menu show only for the comment that is currently being hoverd over. I think I need to use "$this" to make this work but not sure how.

谢谢。

推荐答案

如果我正确读取的格式应为 -

If i'm reading that correctly the format should be-

$(".comment_div").hover(
  function() { $(this).children(".comment_actions").show(); },
  function() { $(this).children(".comment_actions").hide(); }
);

编辑,因为我是一个完整的白痴。

Edit because i'm a complete idiot.

这篇关于JQuery在悬停时显示隐藏类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆