📜  javascript图片在时间后删除 - Javascript代码示例

📅  最后修改于: 2022-03-11 15:04:14.856000             🧑  作者: Mango

代码示例1
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();