1
我希望完成的是编写一个小的jQuery脚本,它允许我获取块的内容并在有人将鼠标放在它上面时触发弹出窗口。在本质上,它将成为一个带有图像的工具提示。悬停时,工具提示显示图像?
我找到的所有教程都是在mouseover上替换图片,或者是仅包含文本的工具提示。下面是代码:
$(document).ready(function() {
$('div#block-block-14.block').hover(
function() {
this.tip = this.title;
$(this).append(
'<div class="toolTipWrapper">'
+ '<div class="toolTipContent"></div>'
);
this.title = "";
this.width = $(this).width();
$(this).find('.toolTipWrapper').css({left:this.width-22})
$('.toolTipWrapper').fadeIn(300);
},
function() {
$('.toolTipWrapper').fadeOut(100);
$(this).children().remove();
this.title = this.tip;
}
);
});
这里是CSS代码:
div#block-block-14.block{ background:url(../images/QuadChartDropShadow.png);}
.toolTipWrapper{width:175px;position:absolute;top:20px;display:none;color:#FFF;font-weight:bold;font-size:9pt}
.toolTipContent{padding: 8 px 15px; background:url(../images/QuadCharDropShadow.png) no-repeat top;}
绝对是!我给了这个镜头,它像一个魅力。非常感谢你,所有。 – Hectron
很高兴帮助:) – shennyL