何时使用slideToggle或slideUp/slideDown [英] When to use slideToggle or slideUp/slideDown

查看:112
本文介绍了何时使用slideToggle或slideUp/slideDown的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们什么时候应该使用slideUp/slideDown以及什么时候在jQuery中使用slideToggle函数? slidetoggle在IE中工作是否有问题?

When should we use slideUp/slideDown and when to use slideToggle functions in jQuery? Does slidetoggle have problems working in IE?

推荐答案

当一个触发器想要向上或向下滑动并且始终希望它执行一个或一个操作时,应该使用slideToggle().其他取决于该元素的当前状态.

You should use slideToggle() when you have a single trigger for an element that you want to slide up or down and you always want it to do one or the other depending on the current state of that element.

如果具有多个触发器或多个效果,则应使用slideUp()slideDown().例如:

You should use slideUp() or slideDown() if you have either multiple triggers or multiple effects. For example:

您想单击链接以使div向下滑动,但是用户需要单击实际的div来将其向上滑动(多个触发器).

You want clicking on a link to make a div slide down, but then the user needs to click on the actual div to slide it back up (multiple triggers).

您想要单击一个按钮以使div向下滑动,但是您想要再次单击该按钮以使其消失(多种效果).

You want clicking on a button to make the div slide down, but you want clicking on the button again to cause it to fade away (multiple effects).

但是,如果将同一个触发/事件同时使用slideUp和SlideDown,则基本上只是在进行slideToggle,但会使自己更难.

But if you are using slideUp and SlideDown together for the same trigger/event, you are basically just doing slideToggle but making it harder on yourself.

我不确定IE和slideToggle是否存在问题.但是我想如果slideToggle有问题,那么任一幻灯片效果也有问题.

I am not sure if there is problem with IE and slideToggle. But I imagine if there is a problem with slideToggle there is a problem with either slide effects also.

这篇关于何时使用slideToggle或slideUp/slideDown的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆