全部,
在下面的代码中,
<html>
<head>
<link type="text/css" href="http://jqueryui.com/latest/themes/base/ui.all.css" rel="stylesheet" />
<script type="text/javascript" src="http://jqueryui.com/latest/jquery-1.3.2.js"></script>
<script src="http://jqueryui.com/latest/ui/effects.core.js"></script>
<script src="http://jqueryui.com/latest/ui/effects.slide.js"></script>
<style type="text/css">
#show { margin: 0px; width: 100px; height: 80px; background: green; border: 1px solid black; position: relative; }
</style>
</head>
<body>
<div id="details" onmouseover="javascript:tooltip(this);">keyword</div>
<div id="show" style="display:none;"></div>
</body>
<script>
function tooltip(el)
{
$("#details").mouseover(function() {
$("#show").show("slide", {}, 1000);
});
}
</script>
</html>
将鼠标悬停在关键字 div 上。应该在鼠标移出时显示绿色网格框。这是如何实现的。
谢谢......
最佳答案
问题是 mouseover 函数中的代码永远不会执行。当发生鼠标悬停时,jQuery 用于将函数重新分配给鼠标悬停,而应该执行它。
进行以下更改:
- 从详细信息 div 中删除 onmouseover:
<div id="details">keyword</div>
- 通过写入加载文档时执行tooltop函数:
<script> $(document).ready(function(){ { $("#details").mouseover(function() { $("#show").show("slide", {}, 1000); }); } </script>
关于jquery slider 和鼠标悬停代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2192483/