使用HTML5和Javascript通过鼠标重设视频 [英] Reset a video on mouse out using HTML5 and Javascript
问题描述
我试图将鼠标悬停后悬停后出现的视频重置为开始,这是链接到我的测试.我在搜索答案中找到了这个但是我不知道该如何做.
I am trying to get the video that appears after the hover to reset to the start once the mouse leaves, here is the link to my test. I found this in my search for an answer But I can not figure it out how to make that work.
Here is where I got the code for the javascript: Link to code
任何帮助或建议都很好.谢谢!:)
Any help or advice would be great. Thank you! :)
推荐答案
由于您的网站使用jQuery:
Since your site uses jQuery:
$(".h5vt").mouseout(function() {
$("video").get(0).currentTime = 0;
})
只需将 mouseout
事件绑定到倒带视频的图像上即可.
Just bind a mouseout
event to the image that rewinds the video.
您应该向视频添加 id
属性,并使用 $(#myvideoid").get(0)
或 document.getElementById("myvideoid)
,而不是在我的示例中使用 $(" video).get(0)
.由于您的视频元素缺少 id
.
You should add an id
attribute to video and access it with $("#myvideoid").get(0)
or document.getElementById("myvideoid")
instead of with $("video").get(0)
as in my example. My selector code is just a workaround due to the fact that your video element lacks an id
.
这篇关于使用HTML5和Javascript通过鼠标重设视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!