Here's a fiddle without any help of a plugin: http://jsfiddle.net/SzR6h/25/
Answer to your comment
Assume that your bigger images have a completely different name, I'd put that name in a data-*-Attribute in the image tag, e.g.
<img src="http://0.s3.envato.com/files/19320511/Scenery%2080x80%20Avatar.png"
data-image-big="url_to_image_big"/>
In your javaScript, you can then get image URL by writing:
var urlBigImage = $img.data('image-big');
Answer from iappwebdev on Stack OverflowVideos
Here's a fiddle without any help of a plugin: http://jsfiddle.net/SzR6h/25/
Answer to your comment
Assume that your bigger images have a completely different name, I'd put that name in a data-*-Attribute in the image tag, e.g.
<img src="http://0.s3.envato.com/files/19320511/Scenery%2080x80%20Avatar.png"
data-image-big="url_to_image_big"/>
In your javaScript, you can then get image URL by writing:
var urlBigImage = $img.data('image-big');
What you are looking for is called a Lightbox. "Fancybox" it is a jQuery Lightbox plugin.
You can find that plugin over here: http://fancybox.net
There is plenty of good documentation about it too and it is very simple to use: http://fancybox.net/howto
Example:
You just have to include all .js and .css files and modify your HTML a little bit:
<a class="my_images" href="bigimage.jpg">
<img src="thumbnail.jpg" alt=""/>
</a>
Then you add the Fancybox:
$("a.my_images").fancybox();
There are a lot of jQuery plugins available for this
Thickbox
LightBox
FancyBox
FaceBox
NyroModal
PiroBox
Thickbox Examples
For a single image
- Create a link element ()
- Give the link a class attribute with a value of thickbox (class="thickbox")
- Provide a path in the href attribute to an image file (.jpg .jpeg .png .gif .bmp)
I like prettyPhoto
prettyPhoto is a jQuery lightbox clone. Not only does it support images, it also support for videos, flash, YouTube, iframes and ajax. Itโs a full blown media lightbox