English 中文(简体)
将jquery animations退回到原来的州
原标题:Reverting jquery animations back to original css states

我翻了一页内容,根据用户的互动情况,每个部分可能因特定职能而消失:

function slideAndFade(id){
    $(id).animate({opacity:  toggle , width:  toggle }, 500);
}

我想建立一种重新定位的功能,将所有内容重新放在网页上。 通过上面的角逐功能追踪所有要素都赢得了t工作,因为目前隐藏的元素将显示出来,目前显示的元素将隐藏起来。

从根本上来说,寻找办法,把所有要素重新回到原来的各州,而不论它们是否是被 j笑的。

感谢

<><>Edit>:

我所需要做的只是以显示:

function revertSlideAndFade(id){
    $(id).animate({opacity:  show , width:  show }, 500);
}

将这一内容放在任何内容上,将确保该要素在本案中重新显现出来。 然而,见Nick swer, 采用更为普遍适用的办法。

最佳回答

如果你能够确定可能纳入这一职能的所有要素,即它们拥有一个类别<代码>。 Elem。

$(function() {
  $(".toggleElem").each(function() {
    var $this = $(this);
    $.data(this,  css , { opacity: $this.css( opacity ), 
                          width: $this.css( width ) });
  });
});

之后,你可以恢复:

function restore() {
  $(".toggleElem").each(function() {
    var orig = $.data(this,  css );
    $(this).animate({opacity: orig.opacity, width: orig.width}, 500);
  });
}
问题回答

暂无回答




相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签