6

我试图对标签的 HTML 5onended事件做出反应,但没有成功。video在下面的代码片段中,我添加了 mouseleave 事件以确保 jQuery 代码正确并且该事件确实激活了该alert()框。

视频播放得很好,但我没有收到onended事件(我alert()没有触发)。

在 Chrome 中进行测试,今天更新到版本 5.0.375.55。

<html>
<head>
<script src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
<script>
$(document).ready(function(){
  $("#myVideoTag").bind('mouseleave onended', function(){
        alert("All done, function!");
  });
});

</script>
</head>
<body>
<video id="myVideoTag" width="640" height="360" poster="Fractal-zoom-1-04-Snowflake.jpg" controls>
    <source src="Fractal-zoom-1-04-Snowflake.mp4" type="video/mp4"></source>
    <source src="Fractal-zoom-1-04-Snowflake.ogg" type="video/ogg"></source>
</video>

<body>
<html>
4

2 回答 2

17

Make sure you're binding to the ended event instead of onended, always leave the on out when binding with jQuery, for example you couldn't do .on("onclick"), you'd do .on("click").

If it helps, there's a full listing of available events for the <video> element here: http://www.w3.org/2010/05/video/mediaevents.html

于 2010-06-02T03:31:28.223 回答
2

我也在寻找这个问题的答案。以下是 jQuery 移动框架对我有用的内容:

$(document).ready(function(){
  $("#idname").bind('ended', function(){
  $.mobile.changePage($('#idofpageyouwantogoto'), 'fade');
  });
});
于 2011-09-17T18:57:45.463 回答