jQuery fadeOut,但不再有 fadeIn 了?
我尝试了这样的事情:
someObject.fadeOut(500, function() {someObject.fadeIn();});
我期望该对象淡出然后重新出现。事实并非如此。它消失了,再也不会回来。我找到了一个如下所示的解决方法:
someObject.fadeOut(500, function() {someObject.show(); someObject.fadeTo(0, 0); someObject.fadeTo(500,1); });
但这感觉真的很尴尬。淡出元素并(稍后)再次淡入的“最佳实践”是什么?
编辑:好的,我尝试更多地解决这个问题。我要淡出的元素是内联 SVG 中的 SVG 组。如果我隐藏一个正常的 HTML 元素,那么一切都会正常。所以我想问题与此有关。我使用的 svg.jquery 扩展名? SVG 和 jQuery 的常见问题?
I tried something like this:
someObject.fadeOut(500, function() {someObject.fadeIn();});
I expected the object to fade out and then to reappear. It doesn't. It fades out and it never comes back. I found a workaround which looks like this:
someObject.fadeOut(500, function() {someObject.show(); someObject.fadeTo(0, 0); someObject.fadeTo(500,1); });
But that feels really awkward. What would be 'best practice' to fade an element out and (later) in again?
EDIT: OK, I tried around the problem somewhat more. The element I am fading is an SVG group in an inline SVG. If I hide a nomal HTML element, then everything works fine. So I guess the problem is connected to that. The svg.jquery extension I use? General problems with SVG and jQuery?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
问题是我试图淡化 SVG 元素。正如我所期望的那样,jQuery 在 SVG 元素上的行为与在 html 元素上的行为不同。
The problem was that I was trying to fade an SVG element. jQuery does not behave equivalently on SVG elements as on html elements as I expected.
你确定这正在发生吗?我尝试了一下,它的表现似乎符合预期。
Are you sure this is happening? I tried this out, and it seems to be behaving as it should.