题
我是比较新的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(); }
);
这工作exept为我拉多评论了,这只会显示在第一个div菜单不管是什么“的评论”是hoverd。我想有菜单仅显示当前正在hoverd过评论。我想我需要用“$这个”,使这项工作,但不知道如何。
感谢。
解决方案
如果即时读取正确的格式应该是 -
$(".comment_div").hover(
function() { $(this).children(".comment_actions").show(); },
function() { $(this).children(".comment_actions").hide(); }
);
编辑因为我一个完整的白痴。
其他提示
这样的事情对我的作品:
<script>
$(document).ready(function() {
$(".container").hover(
function() { $(this).children('.comment_actions').show(); },
function() { $(this).children('.comment_actions').hide(); }
);
});
</script>
<style>
</style>
<table border="1"><tr>
<td class ="container"><br/>
asd<span class="comment_actions">Approve | Delete</span>
</td>
<td class ="container"><br/>
asd <span class="comment_actions">Approve | Delete</span>
</td>
<td class ="container"><br/>
asd<span class="comment_actions"> Approve| Delete</span>
</td>
</tr></table>
不过,你要面对的问题是悬停在显示有一个div操作:无;组。你可能要考虑它包裹在东西是鼠标敏感,然后显示/隐藏,而不是孩子。
不隶属于 StackOverflow