Javascript 将鼠标悬停在上方时激活jquery弹出窗口<;a>;需要更改为<;标签>;
我有一个弹出系统,当你把鼠标悬停在链接上时会显示一个图像。相反,当您将鼠标悬停在Javascript 将鼠标悬停在上方时激活jquery弹出窗口<;a>;需要更改为<;标签>;,javascript,jquery,html,popup,label,Javascript,Jquery,Html,Popup,Label,我有一个弹出系统,当你把鼠标悬停在链接上时会显示一个图像。相反,当您将鼠标悬停在 popup.js /* * Url preview script * powered by jQuery (http://www.jquery.com) * * written by Alen Grakalic (http://cssglobe.com) * * for more info visit http://cssglobe.com/post/1695/easiest-tooltip-an
popup.js
/*
* Url preview script
* powered by jQuery (http://www.jquery.com)
*
* written by Alen Grakalic (http://cssglobe.com)
*
* for more info visit http://cssglobe.com/post/1695/easiest-tooltip-and-image-preview-using-jquery
*
*/
this.screenshotPreview = function(){
/* CONFIG */
xOffset = 130;
yOffset = 60;
// these 2 variable determine popup's distance from the cursor
// you might want to adjust to get the right result
/* END CONFIG */
$("a.screenshot").hover(function(e){
this.t = this.title;
this.title = "";
var c = (this.t != "") ? "<br/>" + this.t : "";
$("body").append("<p id='screenshot'><img src='"+ this.rel +"' alt='image loading...' />"+ c +"</p>");
$("#screenshot")
.css("top",(e.pageY - xOffset) + "px")
.css("left",(e.pageX + yOffset) + "px")
.fadeIn("fast");
},
function(){
this.title = this.t;
$("#screenshot").remove();
});
$("a.screenshot").mousemove(function(e){
$("#screenshot")
.css("top",(e.pageY - xOffset) + "px")
.css("left",(e.pageX + yOffset) + "px");
});
};
// starting the script on page load
$(document).ready(function(){
screenshotPreview();
});
/*
*Url预览脚本
*由jQuery提供支持(http://www.jquery.com)
*
*作者:阿伦·格拉卡里克(http://cssglobe.com)
*
*欲了解更多信息,请访问http://cssglobe.com/post/1695/easiest-tooltip-and-image-preview-using-jquery
*
*/
this.screenshotPreview=函数(){
/*配置*/
xOffset=130;
yOffset=60;
//这两个变量确定弹出窗口与光标的距离
//您可能需要调整以获得正确的结果
/*结束配置*/
$(“a.屏幕截图”).hover(函数(e){
this.t=this.title;
this.title=“”;
var c=(this.t!=”)?“
”+this.t:”;
$(“正文”)。追加(“”+c+”
”;
$(“截图”)
.css(“顶部”(e.pageY-xOffset)+“px”)
.css(“左”(e.pageX+yOffset)+“px”)
.fadeIn(“快速”);
},
函数(){
this.title=this.t;
$(“#屏幕截图”).remove();
});
$(“a.screenshot”).mousemove(函数(e){
$(“截图”)
.css(“顶部”(e.pageY-xOffset)+“px”)
.css(“左”(e.pageX+yOffset)+“px”);
});
};
//在页面加载时启动脚本
$(文档).ready(函数(){
截屏预览();
});
下面是激活弹出窗口的html
HTML:
blabla
我试过:
blabla
并在js$(“label.screenshot”)中更改为此。悬停
,但我只加载图像,没有图像 您遇到的问题是,this.rel
正在访问dom属性rel
,它是a
标签的一个属性,而不是标签的一个属性
将代码更改为$(this).attr('rel')
,这样它将拾取属性
$("body").append("<p id='screenshot'><img src='"+ $(this).attr('rel') ...
$(“body”).append(当它是一个链接时是否工作?您是否检查了图像路径并确保其正确?
$("body").append("<p id='screenshot'><img src='"+ $(this).attr('rel') ...