<分区>
标签 javascript html css
此脚本从我的按钮中删除所有文本并使其成为绿色 block 。
function playSound(soundfile) {
document.getElementById("musicButton").innerHTML =
"<embed src=\"" + soundfile + "\" hidden=\"true\" autostart=\"true\" loop=\"false\" />";
}
<button id="musicButton" class="button" type="button" name="music" onmouseover="playSound('MySong.wav')">Hover Me For Sick Beats!</button>
最佳答案
这消除了对任何 HTML 元素的需求。
function playSound(soundfile) {
var audio = new Audio(soundfile);
audio.play();
}
<button id="musicButton" class="button" type="button" name="music" onmouseover="playSound('MySong.wav')">Hover Me For Sick Beats!</button>
关于javascript - js有问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50067918/