由于新的jquery已经发布,许多使用jquery的动画都会在firefox中出错。我正在使用我制作的这段代码,这也给firefox带来了一些问题——当我只使用remove()
时,它可以工作,但使用fadeOut
时,它不工作。这是我的代码
$("#"+d).fadeOut(300,function(){$("#"+d).remove();});
有人能给我推荐一个更好的代码替代方案吗。jquery 1.8兼容。(它在chrome中工作,但在firefox中不工作)
这是我的完整代码
$(document).on("click", ".glbhn", function (e) {
e.preventDefault();
var d=$(this).attr('id');
var a=$('.gvpgvpxgvp').val();
var nt ='Global';
var info = 'type=' + nt + '&nid=' + d + '&a=' + a;
$.ajax({
type: "POST",
url: "example.php",
data: info,
success: function(html){
$("#"+d).fadeOut(300,function(){$("#"+d).remove();});
totalcounter(a);
$('.globbl').html(html);
}
});
});
适用于我(使用Firefox 14)。您确定已包含jQuery脚本(通过link
标记)并将代码包含在$(document).ready()
中吗?您也可以安装Firebug来查看错误。
或者变量d
没有定义,或者不存在这样的id?
试试这个!
var interval = 0;
function myfrnd(){
if( $("#" + d).css('display','none')){
$(this).remove();
clearInterval(interval);
}
}
$("#"+d).bind('myfrndevt',function(){
interval = setInterval(function(){
myfrnd();
},1000);
});
$("#"+d).fadeOut(300,function(){
$(this).trigger('myfrndevt');
});