用鼠标悬停在图像上显示附加信息
Show additional information with onmouseover a image
我在一个网站上有三个图像,我想使用onmouseover显示每个图像的特定信息。
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="utf-8">
<title>AJAX</title>
<meta name="viewport" content="width=device-width; initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="lib/css/stil.css" />
<script type="text/javascript" src="lib/js/ajaxeinsendeaufgabe2.js"></script>
</head>
<body>
<h1>Zusatzinformationen</h1>
<table>
<tr>
<td><img class="img" src="img/b1.jpg" /></td>
<td id="info0"></td>
</tr>
<tr>
<td><img class="img" src="img/b2.jpg" /></td>
<td id="info1"></td>
</tr>
<tr>
<td><img class="img" src="img/b3.jpg"/></td>
<td id="info2"></td>
</tr>
</table>
</body>
</html>
我现在需要外部Javascript的帮助。如何通过ID编码元素,以便使用onmouseover显示,例如,第一张图片的info0文本,第二张图片的info1文本和第三张图片的info2文本?
也许这样
var resOb = new XMLHttpsRequest ();
window.onload = function() {
document.getElementsByTagName ("img");
function sndReq(0){
document.getElementById ("info0");
}
}
switch(i) {
case 0:
resOb.open('get', 'info0.txt', true);
break;
case 1:
…
}
resOb.onreadystatechange = function() {
handleResponse(i);
}
document.getElementbyID("info0").innerHTML
...
对不起,但我在javascript技能较少
试试这个简单的东西jquery
<div class="someDiv">
<p>Click me here for mouseover image</p>
</div>
<img style="display:none" class="image" src="http://imgur.com/a/63gbF"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script>
$(".someDiv").hover(function() {
$(document).mousemove(function(event) {
$(".image").css({"position":"absolute","left":event.clientX ,"top":event.clientY }).show();
});
});
//end movement with click on the div.
$(document).bind("click",function(){
$(document).unbind("mousemove");
$(".image").hide();
});
</script>
在javascript <style>
#parent #popup {
display: none;
}
#parent:hover #popup {
display: block;
}
</style>
<div id="parent">
This is the main container.
<div id="popup" style="display: none"><img src="http://imgur.com/a/63gbF"></div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script>
var e = document.getElementById('parent');
e.onmouseover = function() {
document.getElementById('popup').style.display = 'block';
}
e.onmouseout = function() {
document.getElementById('popup').style.display = 'none';
}
</script>
相关文章:
- 如何在视频上显示海报图像使用Jquery结束
- 使用服务器上的HTML/js在网页上显示图像
- Cartodb信息窗口未在地图上显示变量
- 将鼠标悬停在图像上时显示文本
- 在图像上显示菜单
- 使用ImageMagick生成图像而不保存到文件,但仍在网站上显示
- 将鼠标悬停在图像上时显示图像
- 在屏幕上显示选择选项图像
- CSS 在图像上显示按钮
- 当用户在文本框中键入时,如何在图像上显示文本
- 如何在图像上显示图标(灯箱缩略图)
- i危险滑块在图像上显示文本
- 如何在图像上显示文本
- 如何用PHP在图像上显示热图?
- 使用Ajax在鼠标悬停在图像上后显示信息
- 用鼠标悬停在图像上显示附加信息
- 点击可以在图像上显示的两个菜单主菜单和搜索框同时打开?它应该打开一个菜单,关闭另一个
- 如何在图像上显示jsPDF数据
- HTML/Javascript在图像上显示数据
- 如何在滚动图像上显示信息,如facebook人标记