我希望当我将鼠标悬停在图像上时,可以通过弹出文本框加载来自 DIV 标签的某些内容。当我将鼠标移开图像时,弹出框应该消失,当我再次将鼠标悬停在图像上时,文本框中的内容应该显示。我将使用 HTML、JQuery、JS 来实现这个功能。如果您能提供一个使用 JQuery load() 方法的解决方案,那将非常有用。请告诉我您的回应。
我希望当我将鼠标悬停在图像上时,可以通过弹出文本框加载来自 DIV 标签的某些内容。当我将鼠标移开图像时,弹出框应该消失,当我再次将鼠标悬停在图像上时,文本框中的内容应该显示。我将使用 HTML、JQuery、JS 来实现这个功能。如果您能提供一个使用 JQuery load() 方法的解决方案,那将非常有用。请告诉我您的回应。
或者,不使用JavaScript:
<div class="tooltip-wrap">
<img src="/some/image/file.jpg" alt="Some Image" />
<div class="tooltip-content">
Here is some content for the tooltip
</div>
</div>
还有这个 CSS:
.tooltip-wrap {
position: relative;
}
.tooltip-wrap .tooltip-content {
display: none;
position: absolute;
bottom: 5%;
left: 5%;
right: 5%;
background-color: #fff;
padding: .5em;
min-width: 10rem;
}
.tooltip-wrap:hover .tooltip-content {
display: block;
}
您也可以尝试一些非常简单的东西,比如:
<acronym title="pop-up text"><img src=...></acronym>
span.tooltip:after {
content: "";
position: absolute;
width: 0;
height: 0;
border-width: 10px;
border-style: solid;
border-color: transparent #FFFFFF transparent transparent;
top: 11px;
left: -24px;
}
title
属性。不需要任何额外的标签或样式,只需一个属性。<p id="icon">Text to hover over</p>
<p id="info" style="display: none">Text to popup</p>
然后,用JavaScript完成它。
<script>
var e = document.getElementById('icon');
e.onmouseover = function() {
document.getElementById('info').style.display = 'block';
}
e.onmouseout = function() {
document.getElementById('info').style.display = 'none';
}
</script>