简体   繁体   中英

jquery - onclick : show the image

I want to display full screen of a image when i click on thumbnail of it.

Images are hardcoded using IMG tag and having class .imagethumb

Images are displayed as thumbnail and when I click on the thumb it should display in a div called #preview , inside #preview I have a IMG tag to display the full screen of clicked image.

How can I achieve it in jquery ?

您应该尝试使用Simplemodal或Fancybox。

This should do the trick:

$('.imagethumb').click(function()
{
    $('#preview').find('img').attr('src', $(this).attr('src'));
});

Once any of your thumbnails with the class .imagethumb are clicked, the src attribute of the img element inside your #preview div is set to the src element of the (clicked) thumbnail.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM