jQuery单击功能不适用于Firefox [英] jQuery click function not working on firefox
本文介绍了jQuery单击功能不适用于Firefox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我写了这个动画脚本,它在chrome上可以正常工作,但在Firefox上却不能工作,我不知道为什么?
I wrote this animate out script and it works fine on chrome, but does not work on Firefox and I cant figure out why?
有什么想法吗?
基本上,它会检查是否单击了特定链接,是否会为某些元素设置动画
Basically, it checks if a particular link is clicked, if it is it animates certain elements
<script>
jQuery(document).ready(function($) {
console.log('here i am on ff');
// ---------------------
var triggers = '.menu-item a, .isotope-item a';
// ---------------------
$(triggers).on('click', function() { //up & out
event.preventDefault();
var href = $(this).attr('href');
// ------------------ add here
changePage('.rt-tpg-isotope', '.isotope-item', 'upAndOut', 100, 0);
changePage('.menu', '.menu-item', 'rightAndOut', 70, 0);
changePage('.vc_single_image-wrapper', 'img', 'leftAndOut', 100, 500);
// ---------------------
setTimeout(function() {window.location = href}, 1000);
});
function changePage(parentDiv,childDiv,divClass, timingV, delayV){
var time = delayV;
$(parentDiv).children(childDiv).each(function(index, value) {
setTimeout(function() {
$(parentDiv).children().eq(index).addClass(divClass);
}, time)
time += timingV;
/*var $this = $(this);
var $yourset = $(parentDiv).children(childDiv);
if ($this[0] === $yourset.last()[0]) {
console.log('is last');
changePage();
} else {
console.log('is not last');
}*/
});
}
});
</script>
推荐答案
您应将事件作为此类函数的参数
You should put event as a parameter of function like this
$(triggers).on('click', function(event e) { //up & out
e.preventDefault();
这篇关于jQuery单击功能不适用于Firefox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文