我一直在寻找一个在鼠标悬停时展开照片的脚本。
这是 JQuery:
this.imagePreview = function(){
/* CONFIG */
xOffset = 10;
yOffset = 30;
// these 2 variable determine popup's distance from the cursor
// you might want to adjust to get the right result
/* END CONFIG */
$("a.preview").hover(function(e){
this.t = this.title;
this.title = "";
var c = (this.t != "") ? "<br/>" + this.t : "";
$("body").append("<p id='preview'><img src='"+ this.href +"' alt='Image preview' />"+ c +"</p>");
$("#preview")
.css("top",(e.pageY - xOffset) + "px")
.css("left",(e.pageX + yOffset) + "px")
.fadeIn("fast");
},
function(){
this.title = this.t;
$("#preview").remove();
});
$("a.preview").mousemove(function(e){
$("#preview")
.css("top",(e.pageY - xOffset) + "px")
.css("left",(e.pageX + yOffset) + "px");
});
};
// starting the script on page load
$(document).ready(function(){
imagePreview();
});
我想在我想要的不同绝对位置展开每张照片。
查看演示:http://cssglobe.com/lab/tooltip/02/
谢谢
问候
最佳答案
要让所有预览发生在同一位置,请更改这些行中的坐标
.css("top",(e.pageY - xOffset) + "px")
.css("left",(e.pageX + yOffset) + "px")
写下你想要的坐标来代替 e.pageY - xOffset
和 e.pageX + yOffset
关于javascript - 修改 Jquery 以在不同位置展开每张照片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9329384/