[英]delete HTMLElement in strict mode
我的圖像不是那么小,因此我已預先加載了它。
//cache the poster
var img = document.createElement("img");
img.src = "http://lorempixel.com/300/200";
// to make sure the poster is loaded before the video player appears
img.addEventListener("load", function() {
//img loaded, show video
});
delete img;
上面的代碼在嚴格模式下給了我這個錯誤
在嚴格模式下不允許在表達式上調用delete
我知道為什么在嚴格模式下不允許刪除。 我的查詢是
PS:someObject.img = createElm,然后刪除屬性是更好的選擇嗎?
嘗試做“刪除”。我認為img.remove()有效
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.