I have encountered an issue while using the code provided in the CodePen link below to paste an image into a Div. The problem is that when I paste a small image, it shows up multiple times within the Div if clicked on after pasting. My goal is to display the image only once and prevent the Div from being filled with redundant copies of the same image.
$('.active').removeClass('active');
$this.addClass('active');
$this.toggleClass('contain');
$width.val($this.data('width'));
$height.val($this.data('height'));
if ($this.hasClass('contain')) {
$this.css({'width':$this.data('width'), 'height':$this.data('height'), 'z- index':'10'})
} else {
$this.css({'width':'', 'height':'', 'z-index':''})
}
})
})