效果图:
存放图片及上传参考
点击新页面打开: http://blog.csdn.net/ful1021/article/details/38555915
HTML代码
<a href="/Upload/Jaeyi/308_20140722102828.JPG" class="tooltip"> <img src="/Upload/Jaeyi/Small/308_20140722102828.JPG" height="40px" alt="输液单" /> </a>
JS代码
<script src="/Scripts/jquery-1.8.3.min.js" type="text/javascript"></script> <script type="text/javascript"> $(function () { var x = 10; var y = 20; $("a.tooltip").mouseover(function (e) { this.myTitle = this.title; this.title = ""; var imgTitle = this.myTitle ? "<br/>" + this.myTitle : ""; var tooltip = "<div id='tooltip'><img src='" + this.href + "' alt='产品预览图'/>" + imgTitle + "</div>"; //创建 div 元素 $("body").append(tooltip); //把它追加到文档中 $("#tooltip") .css({ "top": (e.pageY + y) + "px", "left": (e.pageX + x) + "px" }).show("fast"); //设置x坐标和y坐标,并且显示 }).mouseout(function () { this.title = this.myTitle; $("#tooltip").remove(); //移除 }).mousemove(function (e) { $("#tooltip") .css({ "top": (e.pageY + y) + "px", "left": (e.pageX + x) + "px" }); }); }) </script>
版权声明:本文为博主原创文章,未经博主允许不得转载。