jQuery z-index and animate problem

二次信任 提交于 2019-12-13 05:34:10

问题


I've got some code which animates my images on click and then adds a z-index to it.

What I need now is to when I click the close button I need it to animate back to its original state and then change the z-index back to how it was.

Currently it changes the z-index and then animates so it looks a bit strange

Here's an example

Is it possible to do?

I've tried putting a delay before the z-index change but it still doesn't work

Any ideas?


回答1:


http://jsfiddle.net/hD72c/1/ updated and fixed

All you need to do is change to z-index: 1 as a callback at the end of the animation rather then changing it straight away when close is clicked




回答2:


http://jsfiddle.net/hD72c/3/

I just put the css to replace the original z-index in a callback function (instead of using a delay, since .css() doesn't add to the animation queue, it executes immediately)



来源:https://stackoverflow.com/questions/5052128/jquery-z-index-and-animate-problem

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!