求js大佬,关于Video DOM currentTime 属性传值的问题

qq_34531035 2019-06-26 09:41:00
如何在<button>设置一个时间,如10秒后,自动将10秒传入<script>中myVid.currentTime里面执行。

<button onclick="setCurTime()" type="button">把时间位置设置为 5 秒</button>


<video id="video1" controls="controls">
<source src="/example/html5/mov_bbb.mp4" type="video/mp4">
</video>


<script>
myVid=document.getElementById("video1");
function setCurTime()
{
myVid.currentTime=5; //时间传入口
}
</script>
...全文
121 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
qq_34531035 2019-06-26
  • 打赏
  • 举报
回复
引用 1 楼 天际的海浪 的回复:
<button onclick="setCurTime(5)" type="button">把时间位置设置为 5 秒</button>


<video id="video1" controls="controls">
<source src="/example/html5/mov_bbb.mp4" type="video/mp4">
</video>


<script>
myVid=document.getElementById("video1");
function setCurTime(s)
{
myVid.currentTime=s; //时间传入口
}
</script>
谢谢大佬
天际的海浪 2019-06-26
  • 打赏
  • 举报
回复
<button onclick="setCurTime(5)" type="button">把时间位置设置为 5 秒</button> <video id="video1" controls="controls"> <source src="/example/html5/mov_bbb.mp4" type="video/mp4"> </video> <script> myVid=document.getElementById("video1"); function setCurTime(s) { myVid.currentTime=s; //时间传入口 } </script>

87,923

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧