0

Going through some examples on building a video control panel for an HTML5 element and a a pattern I don't understand popped up here?

http://dev.opera.com/articles/view/introduction-html5-video/#scripting

in particular:

var v = document.getElementById('videoPlayer');
v.addEventListener('timeupdate',updateTimeDisplay,true);

function updateTimeDisplay(e) {
  document.getElementById('timeDisplay').innerHTML = e.target.currentTime;
}

Where did that 'e' come from in the function? What does it reference? Where can I learn more about what it is doing?

4

2 回答 2

0

e 是始终传递给由事件触发的函数的事件。在其中,您可以根据事件找到所有信息,例如 X 和 Y 鼠标位置、触发它的元素等等。

在您的示例中, e.target 指的是触发事件的元素。

于 2012-10-21T11:11:19.083 回答
0

That e is the parameter sent into the callback function updateTimeDisplay, by the videoplayer element. The callback is called when the event 'timeupdate' is triggered in the element referenced by the id videoPlayer.

于 2012-10-21T11:09:24.880 回答