如何檢查嵌入標記是否存在於我的html中。 我已經通過JavaScript檢查嵌入標記是否存在javascript
soundEmbed = document.createElement("embed");
soundEmbed.setAttribute("src", "notify.wav");
soundEmbed.setAttribute("hidden", true);
soundEmbed.setAttribute("autostart", true);
soundEmbed.setAttribute("loop", false);
document.body.appendChild(soundEmbed);
創造了這個標籤,但自從我使用自動刷新和使用appendChild,每次都刷新它創造更多的聲音。
使用appendChild,我想我有很多嵌入標籤。這就是我認爲可能導致額外聲音的原因。
我可以只刪除元素?然後添加孩子?我需要這種方式是有原因的。示例:'if(document.getElementById('soundId'))document.body.removeChild('soundId');'這是正確的嗎? – 2012-02-10 16:46:10
如果soundEmbed存在,我該如何播放聲音?它只在沒有soundEmbed時播放 – 2012-02-10 17:06:22