![](/img/trans.png)
[英]jQuery mouseover link to show hidden div not working on hover exactly
[英]jQuery mouseover link to show hidden div
我在extratorrent网站上遇到了mouseover事件,如下图所示。
alt text http://img3.imageshack.us/img3/4516/usercommment999.jpg
当您将鼠标悬停在用户名链接上时,它会显示一个隐藏的div。 非常整洁和光滑。
我是jQuery的新手。任何人都可以告诉我如何开始在正确的轨道上做到这一点? 谢谢。
更新1:
我写了类似下面的东西试图得到结果。 问题是当我将鼠标移出链接时Div不会停留,它会立即消失。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function()
{
$("#show_div").mouseover(function() { $("#hello").css('visibility','visible'); });
$("#show_div").mouseout(function() { $("#hello").css('visibility','hidden'); });
});
</script>
</head>
<body>
<a id="show_div" href="#">Link text</a>
<div id="hello" style="visibility:hidden;">
<ul>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>
</div>
</body>
</html>
当鼠标悬停在Div上时,如何使Div保持可见?
鼠标悬停在链接文本上时,将div“hello”的Visiblility设置为可见。 然后在鼠标悬停div“hello”时,您还将div“hello”可见性设置为可见。 在鼠标输出div“你好”时,你将其可见性设置为“隐藏”。 像这样的东西:
$("#show_div").mouseover(function() { $("#hello").css('visibility','visible'); });
$("#hello").mouseover(function() { $("#hello").css('visibility','visible'); });
$("#hello").mouseout(function() { $("#hello").css('visibility','hidden'); });
使用简单的HTML:
<div class="div1">Hover me</div>
<div class="div2" style="display: none">Hi, there</div>
当通过div1
你显示div2
,并在用户进入div2
之后隐藏它然后退出:
<script type="text/javascript">
$('.div1').hover(function() {$('.div2').show()});
$('.div2').hover(function() {}, function() {$('.div2').hide()});
</script>
这是一种快速,非最佳的解决方案,但即使两个div不相邻也能正常工作。
用这个
$(document).on(“click”,“#test-element”,function(){});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.