我对 jQuery 比较陌生,我希望能够在鼠标悬停时显示菜单。
这是 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 上显示菜单。我想让菜单仅显示当前悬停在其上的评论。我想我需要使用“$this”来完成这项工作,但我不知道如何。
最佳答案
如果我没看错的话,格式应该是-
$(".comment_div").hover(
function() { $(this).children(".comment_actions").show(); },
function() { $(this).children(".comment_actions").hide(); }
);
关于jquery - 使用 jQuery 在悬停时显示隐藏类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1449574/