在jquery.css()和.animate()之后丢失样式

在jquery.css()和.animate()之后丢失样式,jquery,Jquery,在我的动画之后,我放松了这些css样式。有没有一种方法可以使用类似于()append的方式将它们添加回去?而不是$(this).removeAttr('style') 下面是制作动画的代码 $('#container img').addClass("img_org"); $(this).siblings().css("top", "0px"); $(this).siblings().stop(); $(this).parent().detach();

在我的动画之后,我放松了这些css样式。有没有一种方法可以使用类似于()append的方式将它们添加回去?而不是
$(this).removeAttr('style')

下面是制作动画的代码

  $('#container img').addClass("img_org");
    $(this).siblings().css("top", "0px");
     $(this).siblings().stop();
    $(this).parent().detach();       
    $('.pop_title').css({ "margin-left": "25%", "margin-right": "25%", top: "100px", left: "0", "font-size": "200%"});      
    $('#container').css({ left: image.left, top: image.top, opacity: 1})
                   .animate({marginLeft: '25%',marginRight: '25%', top: '150', left: '0'},200,'easeInCubic', function(){

       $('.nextButton, .prevButton, .zoom_back, .zoom_big, .info, .box_counter ').animate({opacity: 1},500);            
       $('.pop_title').css("font-size", "200%").text(content.navgrid[2][location].title);
            });           

    $('#container ul, #container').css({height: "422px",width: "679px"});

如果您正在谈论删除内联CSS的动画方法,您应该选择不同的方法。 尝试仅添加原始类:

.exampleClass
{
    height:50px;
}
创建该类的div:

<div class="exampleClass"></div>
并删除内联样式以恢复为原始CSS:

$('.exampleClass').removeAttr('style');
您将保留原始CSS,因为它仍然是样式表


removeAttr('style')
可能会“丢失”它们,是的;一般来说,这可能是一种不可取的做法。代码在哪里?将属性保留在类中,并在animationIs之后添加回类。无论如何,我可以只添加style(),而不添加。removeAttr('style');因为它不起作用,我不确定我是否理解你的要求。如果要向元素添加样式,有两种方法。1) 来自样式表2)内联CSS,它是元素内部的样式属性。例如:
——这是内联CSS。您可以删除样式属性,从而删除内联CSS。此时仅保留样式表CSS。
$('.exampleClass').animate({height:'100px'}, 200);
$('.exampleClass').removeAttr('style');