最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Display image with actual sizes onclick - Stack Overflow

programmeradmin2浏览0评论

Before posting here i was testing over 30 or so Jquery image plugins to make my images appear full width when clicked on.

the structure of the HTML is as follows:

<div class="whatever">
   <img id="noonecares" src="pff"></img>
</div>

and not

<a href=".."><img ></img></a>

I'm not talking about zooming in the photos but displaying the whole image onclick instead I'm looking for a Jquery solution preferably.

The solutions that i've been looking into are: zoomfancy easyzoom ajaxzoom ...

Thank y'all

Before posting here i was testing over 30 or so Jquery image plugins to make my images appear full width when clicked on.

the structure of the HTML is as follows:

<div class="whatever">
   <img id="noonecares" src="pff"></img>
</div>

and not

<a href=".."><img ></img></a>

I'm not talking about zooming in the photos but displaying the whole image onclick instead I'm looking for a Jquery solution preferably.

The solutions that i've been looking into are: zoomfancy easyzoom ajaxzoom ...

Thank y'all

Share Improve this question edited Aug 1, 2014 at 17:24 user1578720 asked Aug 1, 2014 at 17:18 user1578720user1578720 173 silver badges8 bronze badges 2
  • you mean in a new browser window – Ehsan Sajjad Commented Aug 1, 2014 at 17:22
  • in a responsive lightbox-like popup window – user1578720 Commented Aug 1, 2014 at 18:06
Add a ment  | 

3 Answers 3

Reset to default 2

If you just want a simple inline image expander then jQuery's toggleClass() is perfect for that. You shrink the images to a fixed size with CSS and then toggle it with a click.

DEMO

Something like

<div>
<img src="http://t1.gstatic./images?q=tbn:ANd9GcRvA_rqizvEgVJhJwLbpgMz7CgGwnjW5BlXHrBNzRwRXsq7O3Gi" />
</div>

script

$("div").on("click", function() {
    window.open($("img").attr("src"), "_blank", "menubar=1,resizable=1"); 
});

?

jsfiddle: http://jsfiddle/chrisbenseler/6GW6M/

This is my approach.

<div class="whatever">
   <img id="noonecares" src="http://imagizer.imageshack.us/v2/100x75q90/21/0ss1.jpg"></img>
</div>

Script

$('.whatever').on('click','#noonecares', function(){
    window.open($(this).attr('src'));
});

JSfiddle: http://jsfiddle/hFp6z/

UPDATE: If you want a plugin to zoom full size, then you can check fancybox or lightbox.

发布评论

评论列表(0)

  1. 暂无评论