使用HTML5和Javascript通过鼠标重设视频 [英] Reset a video on mouse out using HTML5 and Javascript

查看:75
本文介绍了使用HTML5和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.

在这里,我获得了javascript的代码:

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆