I am getting an error Uncaught TypeError: Object [object Object] has no method 'addEventlistner' when adding this code, i can't get my head around it :(
$('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);
});
I am getting an error Uncaught TypeError: Object [object Object] has no method 'addEventlistner' when adding this code, i can't get my head around it :(
$('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);
});
Share
Improve this question
asked Nov 26, 2012 at 20:22
user1853799user1853799
111 silver badge4 bronze badges
1
- Note that the native function is spelled with "listener" (and capitalized). – pimvdb Commented Nov 26, 2012 at 20:25
3 Answers
Reset to default 4Because $('video')
returns a jquery object.
Here is what you can do:
$('video')[0].addEventListener('timeupdate', function(event) {
You would use addEventListener
not addEventlistner
but neither are jQuery methods.
Read this http://api.jquery./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);
});
jQuery objects do not have an addEventListener
method.
Instead, you should call .bind()
.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745417055a4626796.html
评论列表(0条)