Reputation: 133
I'm looking for a way to add an underscore to a filename (and remove "_" from sibling) so it'll show a new "clicked" image.
for example:
Thanks in advance!
$('.img_icons_result').click(function(){
$(this).html($(this).html().replace('_.png', '.png'))
return false;
});
<img src="img/icons/my_image1.png" class="img_icons_result" />
<img src="img/icons/my_image2.png" class="img_icons_result" />
<img src="img/icons/my_image3.png" class="img_icons_result" />
<img src="img/icons/my_image4.png" class="img_icons_result" />
Upvotes: 1
Views: 24
Reputation: 121998
You shouldn't use html. You should just replace the src attr
$('.img_icons_result').click(function(){
$(this).attr('src', $(this).attr('src').replace('_.png', '.png'));
return false;
});
Upvotes: 1