I'm trying to set up a photography website where when a user clicks on a photo they see the full size image. How would I link the CSS to the JavaScript? I cannot change the formatting of the original image. My thought would be to create a class in the JavaScript, but I'm not sure how to do that.
Please help! Thank you!
jQuery(function($) {
$('.image1').click(function() {
var img= $(this).attr("src");
var appear_image = "<div id='appear_image_div' onclick='closeImage()'></div>";
appear_image = appear_image.concat("<img id='appear_image' src='"+img+"'/>");
appear_image = appear_image.concat("<img id='close_image' onClick='closeImage()' src='close.png'/>");
$('body').append(appear_image);
});
});
function closeImage () {
$('#appear_image_div').remove();
$('#appear_image').remove();
$('close_image').remove ();
}
imagefull {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
<div class="item"><p class="gallerycaption">Venice, Italy<br />July 2017</p>
<img src="media\photos_2\portraits\thumbnails\t_italy_1.jpg" alt="Venice, Italy, July 2017" class="image1"/></div>