经过一系列操作后,如何将元素重置为原始状态?
经过一系列动画、添加类和设置 css 样式之后。有没有一种简单的方法可以将元素重置为原始服务器交付状态?
After a bunch of animating, adding classes and setting css styles. is there an easy way to reset an element to be back in its original server delivered state?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
jQuery 使用内联
style
属性设置其操作,因此只需将其设置为''
即可。这假设来自服务器的元素上没有设置内联
style
属性。如果是这样,最好使用样式表。如果该元素必须来自设置了
style
属性的服务器,那么我想您可以将该值缓存在变量中,并在需要时重置它。编辑:
如果需要,您可以从服务器发送带有自定义属性的元素,以记住原始
class
属性。然后您可以随时参考原件。
您甚至可以找到所有具有
originalClass
属性的元素,如下所示。或者查找
class
属性已从原始属性修改的元素。jQuery sets its manipulations using the inline
style
attribute, so just set that to''
.This assumes there were no inline
style
attributes set on the element coming from the server. Better to use style sheets if so.If the element must come from the server with
style
attributes set, then I suppose you could cache the value in a variable, and reset it when needed.EDIT:
If needed, you could send your elements from the server with custom attributes to remember the original
class
attribute, for example.Then you can reference the original anytime you need.
You could even find all elements that have the
originalClass
attribute like this.or find elements where the
class
attribute has been modified from the original.