我正在尝试设置 Qtip2,但在编写 javascript 时遇到了困难。由于某种原因,我的 .hover 代码什么也不做(尝试将其发送到 console.log 来查看是否存在问题并且控制台为空)。你能看一下我的代码并告诉我我做错了什么吗?
谢谢,下面是代码片段
$(document).ready(function() {
$('.mouseover').hover(function() {
console.log("mouseover");
$('mouseover').each(function() {
$(this).qtip({
content: {
text: $(this).next('div')
}
});
});
});
});
.mouseover {
border: 1px solid black;
height: 300px;
width: 300px;
}
.tooltip {
display: none;
}
<html>
<head>
<title>TODO supply a title</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link type="text/css" rel="stylesheet" href="index.css" />
</head>
<body>
<div class='mouseover'>Tooltip testin'</div>
<div class='tooltip'> <b>TOOLTIP</b>
<p>testin</p>
</div>
<script type="text/javascript" src="jquery-213.js"></script>
<script type="text/javascript" src="jquery.qtip.js"></script>
<script type='text/javascript' src='tolltip.js'></script>
</body>
</html>
最佳答案
$(document).ready(function() {
$('.mouseover').hover(function() {
console.log("mouseover");
$('.mouseover').each(function() {
$(this).qtip({
content: { text: $(this).next('div') }
});
});
});
});
你错过了点。希望这有效。
关于javascript - .hover 在我的 div 上没有任何作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28274250/