.click()
:
.main-image
thumb-box
, parents()
(1) parent()
, parents('.image-wrapper').find('.main-image')
..attr('src', '.thumb-box > img')
".thumb-box > img" src
, .thumb-box
src
.
JS Fiddle 1
$('.thumb-box').click(function() {
var theSRC = $(this).find('img').attr('src');
$(this).parents('.image-wrapper').find('.main-image').attr('src', theSRC).fadeIn();
});
" 550 " CSS javascript, (2) CSS ( 3):
JS Fiddle 2
.main-image {
max-height: 550px;
width: auto;
}
----------------------------------------------- -------------------------------
(1)https://api.jquery.com/parents/
(2) //Resize image $('.main-image').each(...)
.higher-than-max
.not-higher-than-max
CSS, - .
(3) max-height: 550px;
250px
300px