我不确定为什么下面的 javascript 函数在 Firefox 中不起作用
function focus_adverts(element_one, element_two){
element_one.on('click', function(){
$(this).one('webkitAnimationEnd mozAnimationEnd oAnimationEnd animationEnd', function(){
element_two.show().addClass('animated flipInY');
element_two.one('webkitAnimationEnd mozAnimationEnd oAnimationEnd animationEnd', function(){
element_one.hide().removeClass('flipOutY flipInY');
});
});
});
}
focus_adverts($('#tv-advertisement'), $('#tv-advertisement-video'));
focus_adverts($('#tv-advertisement-video'), $('#tv-advertisement'));
此功能focus_adverts
似乎根本不起作用。它不运行 $(this).one
内的代码不知何故...
发生这种情况有什么原因吗?
最佳答案
确保您的调用是在 DOM 完成加载后进行的:
$(function(){
focus_adverts($('#tv-advertisement'), $('#tv-advertisement-video'));
focus_adverts($('#tv-advertisement-video'), $('#tv-advertisement'));
});
关于javascript - Firefox 中未定义的函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21093323/