x
 
<!DOCTYPE html>
<html>
<body>
<h3>演示如何创建 AUDIO 元素</h3>
<p>请点击按钮来创建 AUDIO 元素,该元素将播放 .ogg 文件格式的声音。</p>
<button onclick="myFunction()">试一下</button>
<p id="demo"></p>
<script>
function myFunction()
{
var x = document.createElement("AUDIO");
x.setAttribute("src", "/i/horse.mp3");
x.setAttribute("controls", "controls");
document.body.appendChild(x);
document.getElementById("demo").innerHTML = "<b>注释:</b>IE 和 Safari 不支持 .ogg 文件格式。这只是一个例子。如需使其在所有浏览器中运行,您应该在 audio 元素中使用 source 元素。";
}
</script>
</body>
</html>