jquery代码行不能与firefox一起使用

时间:2015-03-26 16:22:31

标签: jquery firefox

我有这行代码在谷歌浏览器中工作,但在mozilla firefox中没有。

$("body").on("click",".removeclass", function(){  
  event.returnValue = false; 
  if( i > 1 ){ 
    $(this).parents('span').remove();
    i--; 
  } 
}); 
你知道吗?

2 个答案:

答案 0 :(得分:1)

您忘记将事件传递给函数,如下所示:

$("body").on("click",".removeclass", function(event){ 
   event.returnValue = false;
   if( i > 1 ){ 
       $(this).parents('span').remove();
       i--;
   }
});


More info in this post.

答案 1 :(得分:0)

解决方案是修改     getPreventDefaul() 同     defaultPrevented() 在jquery.js上 和

$("body").on("click",".removeclass", function(){  
event.returnValue = false; 
if( i > 1 ){ 
$(this).parents('span').remove();
i--; 
} 
});

$("body").on("click",".removeclass", function(event){  
event.returnValue = false;
if( i > 1 ){ 
$(this).parents('span').remove();
i--; 
} 
});