你的位置:首页 > 软件开发 > Java > 移动端点击图片查看大图

移动端点击图片查看大图

发布时间:2015-11-04 10:00:07
一、需求点击图片查看大图,再点大图隐藏。多用于移动端,因为移动端屏幕小,可能需要查看大图。二、代码<!DOCTYPE html><html><meta charset="utf-8"/><head runat=&quo ...

移动端点击图片查看大图

一、需求

点击图片查看大图,再点大图隐藏。多用于移动端,因为移动端屏幕小,可能需要查看大图。

二、代码

<!DOCTYPE html><html><meta charset="utf-8"/><head runat="server"><title>JQuery点击图片查看大图by starof</title><style type="text/css">.exampleImg { height:100px; cursor:pointer;}</style><script src='/images/loading.gif' data-original="http://code.jquery.com/jquery-latest.js"></script><script type="text/javascript">//alert($);// (function (window, undefined) {// var MyJQuery = function () {// window.MyjQuery = window.$ = jQuery; window.$ = MyJQuery;// };// })(window);// alert($);$.fn.ImgZoomIn = function () {bgstr = '<div id="ImgZoomInBG" ><iframe src='/images/loading.gif' data-original="about:blank" frameborder="5px" scrolling="yes" ></iframe></div>';//alert($(this).attr('src'));imgstr = '<img id="ImgZoomInImage" src='/images/loading.gif' data-original="' + $(this).attr('src')+'" onclick=$(\'#ImgZoomInImage\').hide();$(\'#ImgZoomInBG\').hide(); />';if ($('#ImgZoomInBG').length < 1) {$('body').append(bgstr);}if ($('#ImgZoomInImage').length < 1) {$('body').append(imgstr);}else {$('#ImgZoomInImage').attr('src', $(this).attr('src'));}//alert($(window).scrollLeft());//alert( $(window).scrollTop());$('#ImgZoomInImage').css('left', $(window).scrollLeft() + ($(window).width() - $('#ImgZoomInImage').width()) / 2);$('#ImgZoomInImage').css('top', $(window).scrollTop() + ($(window).height() - $('#ImgZoomInImage').height()) / 2);$('#ImgZoomInBG').show();$('#ImgZoomInImage').show();};$(document).ready(function () {$("#imgTest").bind("click", function () {$(this).ImgZoomIn();});});</script></head><body><div><!--第一种写法--><img class="exampleImg" src='/images/loading.gif' data-original="images/03.jpg" id="imgTest"/><!--第二种写法--><img class="exampleImg" src='/images/loading.gif' data-original="images/p1_nav2.png" onClick="$(this).ImgZoomIn();"/></div></body></html>

原标题:移动端点击图片查看大图

关键词:图片

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。