zoukankan      html  css  js  c++  java
  • JQuery预览图片

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <title>jQuery图片预览</title>
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
        <script type="text/javascript">
            var ShowImage = function() {
                xOffset = 10;
                yOffset = 30;
                jQuery("#imglist").find("img").hover(function(e) {
                    jQuery("<img id='imgshow' src='" + this.src + "' />").appendTo("body");
                    jQuery("#imgshow")
                        .css("top", (e.pageY - xOffset) + "px")
                     .css("left", (e.pageX + yOffset) + "px")
               .fadeIn("fast");
                }, function() {
                    jQuery("#imgshow").remove();
                });
    
                jQuery("#imglist").find("img").mousemove(function(e) {
                    jQuery("#imgshow")
                       .css("top", (e.pageY - xOffset) + "px")
                 .css("left", (e.pageX + yOffset) + "px")
                });
            };
    
            jQuery(document).ready(function() {
                ShowImage();
            });
        </script>
        <style type="text/css">
            body{ width:600px; margin:0 auto;}
            img{border:none;}
            ul,li{
             margin:0;
             padding:0;
            }
            li{
             list-style:none;
             float:left;
             display:inline;
             margin-right:10px;
            }
            #imglist img{width:150px;height:120px;}
            #imgshow{
             position:absolute;
             border:1px solid #ccc;
             background:#333;
             padding:5px;
             color:#fff;
             display:none;
         }
        </style>
    </head>
    <body>
    <ul id="imglist">
        <li><a><img src="http://www.jquery001.com/images/demo/35624390.jpg" alt="安以轩" /></a></li>
        <li><a><img src="http://www.jquery001.com/images/demo/35624390.jpg" alt="安以轩" /></a></li>
    </ul>
    </body>
    </html>

    原文地址:http://www.jquery001.com/jquery-image-preview.html

  • 相关阅读:
    指针与数组的区别 —— 《C语言深度剖析》读书心得
    console ouput 与 重定向输出 效率对比
    First day in 阿里
    TestNG 使用入门教程
    Spring简单使用简介
    玩转Spring JUnit+mockito+powermock单元测试(使用详解)
    Spring Boot Junit 单元测试详解
    spring @Value注入map、List、Bean、static变量方式及详细使用
    单元测试Junit使用详解
    Mockito & PowerMock详解
  • 原文地址:https://www.cnblogs.com/lishidefengchen/p/5411747.html
Copyright © 2011-2022 走看看