案例:javascript案例     状态:可编辑再运行    进入竖版
 运行结果 
x
 
1
<!DOCTYPE html>
2
<html>
3
<body>
4
5
<h3>演示如何访问 SOURCE 元素</h3>
6
7
<audio controls>
8
  <source id="mySource" src="/img/horse.mp3" type="audio/mpeg">
9
  <source src="/img/horse.ogg" type="audio/ogg">
10
Your browser does not support the audio element.
11
</audio>
12
13
<p>点击按钮来获得媒体文件的 URL。</p>
14
15
<p id="demo"></p>
16
17
<button onclick="myFunction()">试一下</button>
18
19
<script>
20
function myFunction()
21
{
22
var x = document.getElementById("mySource").src;
23
document.getElementById("demo").innerHTML = x;
24
}
25
</script>
26
27
</body>
28
</html>
29