修改jquery以在单击时不打开图像
Modify jquery to not open the image when click
我发现这个脚本可以在鼠标悬停时展开图像,但当单击图像时,可以在新页面中打开图像。
我想修改脚本,因为我不想在单击时在新页面中打开该图像。
如何修改脚本以不在新页面中打开照片?
这是脚本:
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/
感谢
问候
$('a.preview').click({
function (event) {
event.preventDefault();
});
要使所有预览都发生在同一位置,请更改中这些行的坐标
.css("top",(e.pageY - xOffset) + "px")
.css("left",(e.pageX + yOffset) + "px")
编写所需坐标以代替e.pageY - xOffset
和e.pageX + yOffset
.preventDefault()
函数将为您执行以下操作:
$("a.preview").click(function(event) {
event.preventDefault();
});
相关文章:
- 使图像在单击时展开到不大于浏览器
- 复制图像路径以单击它
- 旋转和取消旋转图像单击与 javascript
- 如何在 HTML 中的图像单击上播放声音
- 在“JQuery 模式”对话框中指定图像单击侦听器
- 在图像单击时触发Brightcove视频播放,并在视频完成后将其隐藏
- 在图像单击时更改正文加载
- 在图像单击时启用 Javascript 功能
- 为什么更改图像单击在PC上不起作用
- 在页面加载时运行 Jquery 函数,而不是在图像单击时运行
- jQuery 旋转函数 - 在图像单击时指定 20% 的旋转
- Jquery 中环绕图像单击事件的链接
- jquery 'change' 事件在表单中的按钮集的图像单击时未触发
- 打开Javascript交换图像.单击
- JQuery赢得't调用图像单击
- JQuery图像单击事件不起作用
- 旋转图像单击Javascript
- 在jquery中输入类型图像单击事件
- 在没有回发的情况下打开图像单击事件中的对话框
- 更改图像单击时下拉选择的值