调用两次 timeupdate 时遇到问题。 我的代码是:
$("video").on(
"timeupdate",
function(event){
alert('work');
}
);
它有效,但如果我这样做:
$('#video').html( $('#newVideo').html());
以前的代码不起作用。
我尝试下一个方法也行不通:
<video id="video">
`$(文档).on( "timeupdate", '视频',
$(文档).delegate('视频',
$("视频").bind(,
$( "视频").live(`
最佳答案
在层次结构较高的元素上调用 .on()
,以确保事件绑定(bind)适用于其下与选择器匹配的任何元素 - 无论该元素当前是否存在。
// this will work for all <video> elements within the document object
$(document).on("timeupdate", 'video', function(event){
alert('work');
});
// if possible change 'document' to something that is
// closer up in the hierarchy to the video elements
关于javascript - 调用两次 timeupdate,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19511253/