<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<style>
/*jQzoom*/
.jqzoom{
border:1px solid #BBB;
float:left;
position:relative;
padding:0px;
cursor:pointer;
}
div.zoomdiv {
z-index: 999;
position : absolute;
top:0px;
left:0px;
width : 200px;
height : 200px;
background: #ffffff;
border:1px solid #CCCCCC;
display:none;
text-align: center;
overflow: hidden;
}
div.jqZoomPup {
z-index : 999;
visibility : hidden;
position : absolute;
top:0px;
left:0px;
width : 50px;
height : 50px;
border: 1px solid #aaa;
background: #ccc;
opacity: 0.5;
-moz-opacity: 0.5;
-khtml-opacity: 0.5;
filter: alpha(Opacity=50);
}
</style>
</head>
<body>
<div class="jqzoom">
<img src="2.jpg" alt="" jqimg="1.jpg"/>
</div>
</body>
<script src="jquery-1.11.3.min.js" type="text/javascript"></script>
<script src="jquery.jqzoom.js" type="text/javascript"></script>
<script>
$(function() {
$(".jqzoom").jqueryzoom({
xzoom: 300, //放大图的宽度(默认是 200)
yzoom: 300, //放大图的高度(默认是 200)
offset: 10, //离原图的距离(默认是 10)
position: "right", //放大图的定位(默认是 "right")
preload: 1
});
});
</script>
</html>

html

//**************************************************************
// jQZoom allows you to realize a small magnifier window,close
// to the image or images on your web page easily.
//
// jqZoom version 2.2
// Author Doc. Ing. Renzi Marco(www.mind-projects.it)
// First Release on Dec 05 2007
// i'm looking for a job,pick me up!!!
// mail: renzi.mrc@gmail.com
//************************************************************** (function($){ $.fn.jqueryzoom = function(options){ var settings = {
xzoom: 200, //zoomed width default width
yzoom: 200, //zoomed div default width
offset: 10, //zoomed div default offset
position: "right" ,//zoomed div default position,offset position is to the right of the image
lens:1, //zooming lens over the image,by default is 1;
preload: 1 }; if(options) {
$.extend(settings, options);
} var noalt=''; $(this).hover(function(){ var imageLeft = $(this).offset().left;
var imageTop = $(this).offset().top; var imageWidth = $(this).children('img').get(0).offsetWidth;
var imageHeight = $(this).children('img').get(0).offsetHeight; noalt= $(this).children("img").attr("alt"); var bigimage = $(this).children("img").attr("jqimg"); $(this).children("img").attr("alt",''); if($("div.zoomdiv").get().length == 0){ $(this).after("<div class='zoomdiv'><img class='bigimg' src='"+bigimage+"'/></div>"); $(this).append("<div class='jqZoomPup'> </div>"); } if(settings.position == "right"){ if(imageLeft + imageWidth + settings.offset + settings.xzoom > screen.width){ leftpos = imageLeft - settings.offset - settings.xzoom; }else{ leftpos = imageLeft + imageWidth + settings.offset;
}
}else{
leftpos = imageLeft - settings.xzoom - settings.offset;
if(leftpos < 0){ leftpos = imageLeft + imageWidth + settings.offset; } } $("div.zoomdiv").css({ top: imageTop,left: leftpos }); $("div.zoomdiv").width(settings.xzoom); $("div.zoomdiv").height(settings.yzoom); $("div.zoomdiv").show(); if(!settings.lens){
$(this).css('cursor','crosshair');
} $(document.body).mousemove(function(e){ mouse = new MouseEvent(e); /*$("div.jqZoomPup").hide();*/ var bigwidth = $(".bigimg").get(0).offsetWidth; var bigheight = $(".bigimg").get(0).offsetHeight; var scaley ='x'; var scalex= 'y'; if(isNaN(scalex)|isNaN(scaley)){ var scalex = (bigwidth/imageWidth); var scaley = (bigheight/imageHeight); $("div.jqZoomPup").width((settings.xzoom)/scalex ); $("div.jqZoomPup").height((settings.yzoom)/scaley); if(settings.lens){
$("div.jqZoomPup").css('visibility','visible');
} } xpos = mouse.x - $("div.jqZoomPup").width()/2 - imageLeft; ypos = mouse.y - $("div.jqZoomPup").height()/2 - imageTop ; if(settings.lens){ xpos = (mouse.x - $("div.jqZoomPup").width()/2 < imageLeft ) ? 0 : (mouse.x + $("div.jqZoomPup").width()/2 > imageWidth + imageLeft ) ? (imageWidth -$("div.jqZoomPup").width() -2) : xpos; ypos = (mouse.y - $("div.jqZoomPup").height()/2 < imageTop ) ? 0 : (mouse.y + $("div.jqZoomPup").height()/2 > imageHeight + imageTop ) ? (imageHeight - $("div.jqZoomPup").height() -2 ) : ypos; } if(settings.lens){ $("div.jqZoomPup").css({ top: ypos,left: xpos }); } scrolly = ypos; $("div.zoomdiv").get(0).scrollTop = scrolly * scaley; scrollx = xpos; $("div.zoomdiv").get(0).scrollLeft = (scrollx) * scalex ; });
},function(){ $(this).children("img").attr("alt",noalt);
$(document.body).unbind("mousemove");
if(settings.lens){
$("div.jqZoomPup").remove();
}
$("div.zoomdiv").remove(); }); count = 0; if(settings.preload){ $('body').append("<div style='display:none;' class='jqPreload"+count+"'>sdsdssdsd</div>"); $(this).each(function(){ var imagetopreload= $(this).children("img").attr("jqimg"); var content = jQuery('div.jqPreload'+count+'').html(); jQuery('div.jqPreload'+count+'').html(content+'<img src=\"'+imagetopreload+'\">'); }); } } })(jQuery); function MouseEvent(e) {
this.x = e.pageX;
this.y = e.pageY;
}

jquery.jqzoom.js

class名是jqzoom的div中,img的src属性中放的是小图的路径,jqimg属性中放的是对应大图的路径

jqury.jqzoom插件--放大镜的更多相关文章

  1. jquery中用jqzoom实现放大镜效果

    使用的jqzoom 插件实现的放大镜的效果 jqzoom 里面的代码 : 直接copy就好 //**************************************************** ...

  2. jqzoom插件图片放大功能的一些BUG

    建议使用cloud-zoom插件,jqzoom插件就不要使用了 点击查看——图片放大镜——jQuery插件Cloud Zoom 刚开始使用的是jqzoom插件,但问题太多了,就不说插入到页面中使用了, ...

  3. js插件---放大镜如何使用

    js插件---放大镜如何使用 一.总结 一句话总结:一张高清图片被用了两次,一次做缩略图,一次做放大后显示用的的图片(其实这个图片就是高清图片本身,而且是部分) 14 <figure class ...

  4. Jquery的jqzoom插件的使用(图片放大镜)

    今天学习一下,图片放大镜功能,需要使用插件JQzoom 引入文件 <script type="text/javascript" src="js/jquery.min ...

  5. jqzoom图片放大镜

    jqzoom是一个图片放大器插件.它功能强大,使用简便! 引入js与css: <script type="text/javascript" src="js/jque ...

  6. jqzoom插件

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"/> <title> ...

  7. jquery jqzoom插件练习

    <!DOCTYPE html> <html lang="en" xmlns="http://www.w3.org/1999/xhtml"> ...

  8. 使用jqzoom插件时

    [javascript] view plaincopy /*使用jqzoom*/ $(function() { $(".jqzoom").jqueryzoom({ xzoom: 3 ...

  9. jquery.jqzoom.js图片放大镜

    jqzoom插件实现图片放大镜效果 1. jquery.jqzoom.js //************************************************************ ...

随机推荐

  1. 【Java】集合(List、Set)遍历、判断、删除元素时的小陷阱

    开发中,常有场景:遍历集合,依次判断是否符合条件,如符合条件则删除当前元素. 不知不觉中,有些陷阱,不知你有没有犯. 一.漏网之鱼-for循环递增下标方式遍历集合,并删除元素 如果你用for循环递增下 ...

  2. 一个Public的字段引起的,谈谈继承中的new

    一直觉得对c#面向对象这块已经掌握的很好了,因为正常情况下字段一般我们设计成私有的,今天突然想到一个实验,如下有两个很简单的类: public class Farther { ; public vir ...

  3. 我的android学习经历19

    怎样在标题栏中显示进度条 import android.app.Activity;import android.os.Bundle;import android.view.Window; public ...

  4. DataTables warning : Requested unknown parameter '5' from the data source for row 0

    在该项目中我使用了jquery.dataTables.js来作为我的前端数据表格. 表格的官网地址:https://www.datatables.net/ 一.jsp部分代码片段如下: <tab ...

  5. FRM-10001, FRM-10002, FRM-10003 Oracle Form Builder Error Solution

    These errors occurred usually due to forms connection problem or some internal problem, the solution ...

  6. Creating, Stopping, Re-Starting and Deleting a Timer in Oracle Forms

    I have written many posts previously on Timers in Oracle Forms like how to change images randomly wi ...

  7. Logical Databases逻辑数据库

    声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...

  8. Codeforces Round #380 (Div. 2, Rated, Based on Technocup 2017 - Elimination Round 2) E. Subordinates 贪心

    E. Subordinates time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...

  9. hiho #1050 : 树中的最长路 树的直径

    #1050 : 树中的最长路 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 上回说到,小Ho得到了一棵二叉树玩具,这个玩具是由小球和木棍连接起来的,而在拆拼它的过程中, ...

  10. 利用EL表达式+JSTL在客户端取得数据 示例

    <%@page import="cn.gbx.domain.Address"%> <%@page import="cn.gbx.domain.User& ...