未捕获的TypeError:对象没有方法’addEventlistner’

我收到一个错误未捕获的TypeError:对象[对象对象]在添加此代码时没有方法’addEventlistner’,我无法理解它:(

$('video').addEventlistner('timeupdate', function(event) { var current = Math.round(event.target.currentTime * 1000); var total = Math.round(event.target.duration * 1000); $('temps_total').empty().appendText(total); $('temps_courant').empty().appendText(current) $('temps_restant').empty().appendText(total - current); }); 

您可以使用addEventListener而不是addEventlistner 但它们都不是jQuery方法。

阅读http://api.jquery.com/on/

 $('video').on('timeupdate', function(event) { var current = Math.round(event.target.currentTime * 1000); var total = Math.round(event.target.duration * 1000); $('temps_total').empty().appendText(total); $('temps_courant').empty().appendText(current) $('temps_restant').empty().appendText(total - current); }); 

因为$('video')返回一个jquery对象。

这是你可以做的:

 $('video')[0].addEventListener('timeupdate', function(event) { 

jQuery对象没有addEventListener方法。
相反,你应该调用.bind()