Hi a newbie here can someone help with this problem i'm having with the image decscription of my image gallery, when the thumbnail is clicked the description shows up but when using the next and previous button i can't get it to show `//image click
$('.pic img').on("click", function(){
img_index = $(this).parent().index();
$('.pic img').css('border', 'none');
$(this).css('border','2px solid #4f4f4f');
$('pic').css('marginLeft', '0')
$(this).parent().css('marginLeft', '3px');
image_address = $(this).attr('src');
list = image_address.split('/', 4);
name = list[3];
$('#display img').fadeOut(150, function() {
$('#display').html("<img class='display_img' src='img/photography/" + name + "'> ");
$('#display img').fadeOut(0);
$('#display img').fadeIn(150);
});
$(".img_caption").children().remove();
$(this).next('#caption').fadeIn().appendTo('.img_caption');
$('#thumbs').hide();
});`
this is the previous button
// previous button
$('body').on('click', '#left', function(){
if (img_index == 0) {
img_index = $('.pic').last().index();
}
else{
img_index = img_index - 1;
}
image_address = $('.pic').eq(img_index).find('img').attr('src');
list = image_address.split('/', 4);
name = list[3];
$('#display img').fadeOut(150, function () {
$('#display').html("<img class='display_img' src='img/photography/" + name + "'> ");
$('#display img').fadeOut(0);
$('#display img').fadeIn(150);
});
$('#display').html("<img class='display_img' src='img/photography/" + name + "'> ");
$('.pic img').css('border', 'none');
$('.pic').eq(img_index).find('img').css('border', '2px solid #4f4f4f');
$('pic').css('marginLeft', '0')
$('.pic').eq(img_index).css('marginLeft', '3px');
});
this is the next button // next button
$('body').on('click', '#right', function () {
var last_index = $('.pic').last().index();
if (img_index == last_index) {
img_index = $('.pic').first().index();
}
else {
img_index = img_index + 1;
}
image_address = $('.pic').eq(img_index).find('img').attr('src');
list = image_address.split('/', 4);
name = list[3];
$('#display img').fadeOut(150, function () {
$('#display').html("<img class='display_img' src='img/photography/" + name + "'> ");
$('#display img').fadeOut(0);
$('#display img').fadeIn(150);
});
$('#display').html("<img class='display_img' src='img/photography/" + name + "'> ");
$('.pic img').css('border', 'none');
$('.pic').eq(img_index).find('img').css('border', '2px solid #4f4f4f');
$('pic').css('marginLeft', '0')
$('.pic').eq(img_index).css('marginLeft', '3px');
$(".img_caption").children().remove();
});
and this is the html
<div class="gallery-wrapper">
<div class="gallery">
<div id="thumbs">
<div class="pic item-1">
<img src="img/photography/thumbs/1.jpg" alt="" class="photo">
<div id="caption">This is image 1</div>
</div>
<div class="pic medium">
<img src="img/photography/thumbs/2.jpg" alt="" class="photo">
<div id="caption">This is image 2</div>
</div>
<div class="pic tall">
<img src="img/photography/thumbs/3.jpg" alt="" class="photo">
<div id="caption">This is image 3</div>
</div>
<div class="pic medium">
<img src="img/photography/thumbs/4.jpg" alt="" class="photo">
<div id="caption">This is image 4</div>
</div>
<div class="pic medium">
<img src="img/photography/thumbs/5.jpg" alt="" class="photo">
<div id="caption">This is image 5</div>
</div>