使用$(this)添加不同<p>'s在一组图像的顶部
Way to use $(this) to add different <p>'s on top of a set of images?
好吧,标题可能令人困惑,但这是我想要的,假设我有4个图像。
<img src="images/first.jpg" title="something" class="group">
<img src="images/fourth.jpg" title="something2" class="group">
<img src="images/sixth.jpg" title="something3" class="group">
<img src="images/tenth.jpg" title="something4" class="group">
现在,当我将鼠标悬停在这些图像上时,我希望在悬停的图像顶部出现一个包含单词的框,但是,根据图像的内容(first.jpg、quadrup.jpg、sixth.jpg、10th.jpg),我希望单词表达不同的内容,只是框应该是相同的。你知道我该怎么做吗?
包含jQuery的最简单方法是从CDN(如Google CDN )中使用它
Ex
<html>
<head lang="en">
<meta charset="utf-8">
<title>Custom Plunker</title>
<link rel="stylesheet" type="text/css" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/redmond/jquery-ui.css">
<link rel="stylesheet" type="text/css" href="style.css">
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js"></script>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.js"></script>
<script type="text/javascript">
jQuery(function($){
$( document ).tooltip({
track: true
});
});
</script>
</head>
<body>
<img src="http://www.google.co.in/images/srpr/logo4w.png" title="one" />
<img src="http://www.google.co.in/images/srpr/logo4w.png" title="two" />
<img src="http://www.google.co.in/images/srpr/logo4w.png" title="Three" />
<img src="http://www.google.co.in/images/srpr/logo4w.png" title="Fout" />
</body>
</html>
演示:Plunker
尝试显示&定位隐藏的DIV.
<img src="images/first.jpg" class="myImage" title="something" class="group">
<img src="images/second.jpg" class="myImage" title="something" class="group">
<!-- more images.. -->
<div id='imageInfo' style='display:hidden; position:absolute;'>
Populate some details here..
<div id='imageInfo_title'></div>
<div>
$('.myImage').hover(
function(){ showImageInfo( $(this));},
('#imageInfo').hide();
);
function showImageInfo (fromImg) {
var infoDiv = ('#imageInfo');
infoDiv.show();
infoDiv.position( {
my: "left top",
at: "left top",
offset: "0 0",
of: fromImg,
collision: "flip"
});
// now get some details from the <IMG>, and populate the Info Div with them.
// -- something like this..
var title = fromImg.attr( 'title');
('#imageInfo_title').text( title);
}
相关文章:
- 背景图像顶部的滚动图像不移动
- 如何在引导程序中将输入文本框嵌入到图像的顶部
- 使用paperjs在图像顶部绘制
- HTML5 中图像顶部的超链接文本
- 引导进度条,顶部附有图像
- 如何在 jQuery 中将可点击的图像定位到浏览器顶部
- 如何停止幻灯片放映隐藏文本和图像跳到顶部,而下一张幻灯片进来
- 图像旋转背景 js 跳转到页面顶部
- HTML5 画布 - 我的线条/弧线没有出现在图像顶部
- 当圆形图像在圆轮中发生变化时,如何在顶部显示标签
- 在图像顶部显示文本
- 图像映射顶部的文本
- 使用 JavaScript 在鼠标悬停时在内容顶部查看放大的图像
- 在HTML和Javascript中的图像顶部“绘制”
- 获取图像以覆盖在表格顶部
- 在图像顶部添加数字
- 用户在图像顶部绘制形状
- 如何在图像顶部放置标记,标记的位置相对于图像给出
- 在背景图像顶部定位按钮
- 将元素从图像顶部定位 50%