第九区-Jquery超级群

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 709|回复: 5

鼠标滑过图片,图片变大 [复制链接]

Rank: 7Rank: 7Rank: 7

发表于 2011-7-8 10:53:59 |显示全部楼层
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <title>yj511 - - 鼠标滑过图片,图片变大</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6. <SCRIPT LANGUAGE="JavaScript" src='jquery-1.4.4.js'></SCRIPT>

  7. <script type="text/javascript">
  8. (function($){

  9. $.fn.zoomi = function() {
  10. $(this).filter("img").each(function(){
  11. if(!this.z) {
  12. $(this).zoom1().mouseover(function(){$(this).zoom2().show();});
  13. $(this.z).mouseout(function(){$(this).hide();}); }
  14. });
  15. return this;
  16. }

  17. $.fn.zoom1 = function() {
  18. $(this).each(function(){
  19. var e = this;
  20. $(e).css({'position':'relative','z-index':'8'}).after('<img class="'+e.className+'">');
  21. e.z = e.nextSibling;
  22. $(e.z).removeClass("zoomi").addClass("zoom2").attr("src",e.alt || e.src)
  23. .css({'position':'absolute','z-index':'10'});
  24. $(e.z).hide();
  25. });
  26. return this;
  27. }

  28. $.fn.zoom2 = function() {
  29. var s = [];
  30. this.each(function(){
  31. var e = this;
  32. if(!e.z) e = $(e).zoom1()[0]; s.push(e.z);
  33. if(!e.z.complete) return;
  34. if(!e.z.width) { $(e.z).show(); e.z.width=e.z.width; $(e.z).hide(); }
  35. $(e.z).css({left:$(e).offsetLeft()-(e.z.width-e.scrollWidth)/2+'px',
  36. top:$(e).offsetTop()-(e.z.height-e.scrollHeight)/2+'px'});
  37. });
  38. return this.pushStack(s);
  39. }

  40. $.fn.offsetLeft = function() {
  41. var e = this[0];
  42. if(!e.offsetParent) return e.offsetLeft;
  43. return e.offsetLeft + $(e.offsetParent).offsetLeft(); }

  44. $.fn.offsetTop = function() {
  45. var e = this[0];
  46. if(!e.offsetParent) return e.offsetTop;
  47. return e.offsetTop + $(e.offsetParent).offsetTop(); }

  48. $(function(){ $('img.zoomi').zoomi(); });

  49. })(jQuery);

  50. </script>
  51. <script type="text/javascript">
  52. $(function(){
  53. for(i=1; i<=5; ++i)
  54. $('#bleach img.zoomi').zoomi();
  55. });
  56. </script>
  57. </head>
  58. <body>
  59. <div id="bleach"><a href="#"><img height="110" src="master-css-div-shadow.jpg" class="zoomi"/></a><img class="zoom2" src="master-css-div-shadow.jpg" style="display: none;"/><a href="#"><img height="110" src="master-css-div-shadow.jpg" class="zoomi"/></a><img class="zoom2" src="master-css-div-shadow.jpg" style="display: none;"/><a href="#"><img height="110" src="master-css-div-shadow.jpg" class="zoomi"/></a><img class="zoom2" src="master-css-div-shadow.jpg" style="display: none;"/><a href="#"><img height="110" src="master-css-div-shadow.jpg" class="zoomi" /></a><img class="zoom2" src="4.jpg" style="display: none;"/><a href="#"><img height="110" src="5.jpg" class="zoomi"/></a><img class="zoom2" src="5.jpg" style="display: none;"/></div>
  60. </body>
  61. </html>
复制代码

附件: 你需要登录才可以下载或查看附件。没有帐号?立即注册

Rank: 7Rank: 7Rank: 7

发表于 2011-7-8 10:55:27 |显示全部楼层

使用道具 举报

Rank: 7Rank: 7Rank: 7

发表于 2011-7-8 10:59:07 |显示全部楼层
king 发表于 2011-7-8 10:55

谢谢惠顾

使用道具 举报

Rank: 7Rank: 7Rank: 7

发表于 2011-7-8 11:10:55 |显示全部楼层
很好很强大,我也会做的说
别人笑我太淫荡 我笑他人不开放

使用道具 举报

Rank: 7Rank: 7Rank: 7

发表于 2011-7-8 13:44:31 |显示全部楼层
想说的是,图片上这本书,我也有..........

使用道具 举报

Rank: 7Rank: 7Rank: 7

发表于 2011-7-8 22:38:36 |显示全部楼层

oooO ↘┏━┓ ↙ Oooo
( 踩)→┃踩┃ ←(踩 )
  \ ( →┃√┃ ← ) /
  \_)↗┗━┛ ↖(_/
不积跬步无以至千里
不积小流无以成江海

阿良的小站

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

Archiver|第九区-Jquery超级群    点击这里加入此群 点击这里加入此群

GMT+8, 2012-2-8 09:14 , Processed in 0.066844 second(s), 16 queries .

Powered by Discuz! X2

© 2001-2011 Comsenz Inc.

回顶部