首页
极刻
圈子
教程
开源
登录 / 注册
返回教程:Javascript 参考手册
TRY RUN / 在线示例
Javascript 参考手册 尝试一下
Javascript 参考手册 尝试一下
源代码
运行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>安科教程(www.ancii.com)</title> </head> <body> <audio id="myAudio" controls> <source src="/statics/demosource/horse.ogg" type="audio/ogg"> <source src="/statics/demosource/horse.mp3" type="audio/mpeg"> 您的浏览器不支持 audio 元素。 </audio><br> <button onclick="getCurTime()" type="button">获取当前时间位置</button> <button onclick="setCurTime()" type="button">设置时间点为 1 秒 </button> <script> var x = document.getElementById("myAudio"); function getCurTime(){ alert(x.currentTime); } function setCurTime(){ x.currentTime = 1; } </script> </body> </html>
运行结果