My question is this: I want to put some images designed in phothoshop as sample images on my page, they are cut in the shape of a diamond, but I want you to click on it to show me another image, which I have inside another folder of images ... I explain.
I have the X image that is in src="img/x.png"...
but I want that when giving click to me it shows me the image And ... that this in another different folder ....
On how to do it with js, but I do not want to repeat the code, how do I do it efficiently? ... the code I'm using is this
$('.img').click(function(e){
var modal = '<div class="modal" id="modal"><img src="img/section2/mst/Asset8.jpg" class="modal-img"><div class="modal-btn" id="modal-btn">X</div></div>';
$('body').append(modal);
$('#modal-btn').click(function(){
$('#modal').remove();
});
});
But there are 12 images, I do not want to repeat this code 12 times for each image, How do I make a single code in jquery
for the 12 images?