JavaScript gambar hapus setelah waktu

function rockImage() {
    const img = document.createElement('img');
    img.src = 'https://via.placeholder.com/100';
    img.setAttribute('width', '100');
    
    const parent = document.getElementById('div');
    parent.appendChild(img);
    
    setTimeout(() => parent.removeChild(img), 3000);
}

rockImage();
Lamprey