Img Thumbnail Click Replace Div Text Value With Thumbnail Title
JSFIDDLE HERE If you look at the js fiddle you will find clicking the thumbail changes the image aswell as the .currentimgtitle text value but it changes all .currentimgtitle text
Solution 1:
While I see you've already accepted an answer, this approach seems to work pretty well:
$('.minicontainer img').click(
function(){
var miniImgSrc = this.src,
imgTitle = this.title,
$container = $(this).closest('.imgcontainer');
$container
.find('.presentimg')
.attr('src',miniImgSrc);
$container
.find('.currentimgtitle')
.attr('title',imgTitle)
.text(imgTitle);
});
References:
Solution 2:
why don't you change
$(".currentimgtitle").text(textval);
to
$(this).closest(".imgcontainer").find(".currentimgtitle").text(textval);
like you did a few lines higher ?
Solution 3:
try this example, a bit cleaner. For the next step i`ve better wrap it in for no js users.
Post a Comment for "Img Thumbnail Click Replace Div Text Value With Thumbnail Title"