A plugin to enlarge images on touch, click, or mouseover.

Demo

Hover

Grab

Released under the MIT License, source on Github (changelog)

Download

Compatible with: jQuery 1.7+ in Chrome, Firefox, Safari, Opera, Internet Explorer 7+.

Install via NPM

npm install jquery-zoom

Instructions

Zoom appends html inside the element it is assigned to, so that element has to be able to accept html, like <a> , <span> , <li> , <div> , etc. This excludes <img> elements (see below).

$( document ).ready( function ( ) { $( 'a.photo' ).zoom({url: 'photo-big.jpg' }); }); $( document ).ready( function ( ) { $( 'a.photo' ).zoom({ url: 'photo-big.jpg' , callback: function ( ) { $( this ).colorbox({href: this .src}); } }); });

To use zoom with img elements, they will need to be wrapped with another element. It is impossible to read some layout related CSS styles from JavaScript (percent-based width and height, margins set to auto, etc.) so the safe thing to do is to defer this change to individual site owners. The following is all that is needed in some cases:

$( document ).ready( function ( ) { $( 'img' ) .wrap( '<span style="display:inline-block"></span>' ) .css( 'display' , 'block' ) .parent() .zoom(); });

Removing Zoom

Trigger the zoom.destroy event to remove zoom from an element:

$( '#example' ).zoom(); $( '#example' ).trigger( 'zoom.destroy' );

Settings