i am trying to remove image by clicking on it after i create 'img' element using createElement but i cant remove the image , whats wrong with the removes function in my code ? here is my code :
function generateCat(){
var image = document.createElement('img')
var div = document.getElementById('flex-cat-gen');
image.src= ('image.jpg');
div.appendChild(image);
}
document.getElementsByTagName('img').onclick = function removes() {
document.getElementsByTagName('img').remove();
}