JQuery 切换并显示慢/快
我想使用 JQuery 切换对象。我只能显示/隐藏对象,并且我想慢慢地而不是立即显示/隐藏它们。
$("#txtA").toggle(type == "A");
我不知道如何在上面的代码中添加“.show('slow')”。请帮我。谢谢。
I want to toggle objects using JQuery. I can just only show/hide objects and I want to show/hide them slowly rather than immediately.
Showing and Hiding of Objects in JQuery
$("#txtA").toggle(type == "A");
I don't know how to add ".show('slow')" on the above code. Please help me. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
文档说
.toggle
没有重载,两者都需要boolean and 允许您指定缓动参数:但是,文档还说:
相当于:
因此,使用这个事实:
并且,不,抱歉,您无法避免像这样写出来这。
无论如何,想要调用名为“toggle”的函数但指定是要显示还是隐藏似乎很奇怪。
The documentation says that there is no overload for
.toggle
that both takes a boolean and allows you to specify an easing parameter:However, the documentation also says that:
is equivalent to:
So, use that fact:
And, no, sorry, you can't avoid writing it out like this.
It seems bizarre, anyway, to want to call a function named "toggle" but specify whether you're going to show or hide.
尝试:
Try: