javascript - jQuery 图像悬停在多个动态图像之上

标签 javascript jquery html css

好的,所以我有一个完整的图像表,并且只想在悬停时始终在每个图像的右下角显示一个小图标。任何想法我如何做到这一点?现在我有了这个,它只是每次都在同一个地方显示悬停图像……它需要显示在悬停图像的顶部。谢谢!

.enlargeImage {
background:url(images/xxx) no-repeat;
position:absolute;
width:16px;
height:14px;
z-index:200;
display:none;
}

$('.table_imageThumbs a').mouseover(function(){
            $(this).show('.enlargeImage');
        });


<div class="enlargeImage"></div>

<table width="408" class="table_imageThumbs">
                  <tr>
                    <td width="102" class="td_thumb"><a><image width="75" height="97" class="img_vertThumb"></a></td>
                    <td width="102"><a><image width="75" height="97" class="img_vertThumb"></a></td>
                    <td width="102"><a><image width="75" height="97" class="img_vertThumb"></a></td>
                    <td width="102"><a><image width="75" height="97" class="img_vertThumb"></a></td>
                  </tr>
</table>

最佳答案

我会使用 jQuery 在悬停在 a 标记之后动态附加一个 .enlargeImage 元素,并为所有表格单元格提供一个 position: relative .enlargeImage 一个 right: 0;底部:0。您必须在 mouseOut 上(悬停结束时)再次删除 div

但是,我在这里的某处读到,表格单元格内的绝对定位可能存在问题(现在找不到...),因此它可能无法按预期工作。

一些未经测试的示例代码:

el = $("<div>")
     .addClass("enlargeImage");

$('.table_imageThumbs a').hover(
  function() {
    el.appendTo(this);
  },
  function() {
    el.remove();
  });

关于javascript - jQuery 图像悬停在多个动态图像之上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4949063/

相关文章:

javascript - 为什么使用粗箭头而不是直接赋值?

javascript - 正则表达式 javascript 搜索前两位数字并确保所有字符之后都是字母

javascript - 如何从单选按钮获取 jquery 或 JS 中的自定义属性值?

javascript - 如何通过数组 Javascript 拆分对象数组

javascript - rake 中止!找不到 JavaScript 运行时

php - 如何将额外变量传递给 Jquery UI 可排序

jquery - 如何添加适合 div 的视频

html - 垂直对齐标题元素

html - 轴字体不需要加粗

html - 我正在尝试使用 css 设置页脚,我需要有 2 行