jQuery slideToggle奇怪的行为 [英] jQuery slideToggle strange behaviour
问题描述
我真的需要帮助,我看不到明显的东西,通常最好寻求帮助. 我在一个12列的网格中有4个div,每个div都是可单击的,并且在单击时应在其下方显示相应的div,该div最初设置为display:none.
i really need help, i can't see something that is obvious, and usually then it is the best to ask for help. I have 4 divs in a 12 column grid.Each div is clickable, and when clicked should display the corresponding div beneath it, that is initially set to display:none.
只要我按从头到尾的顺序单击它们,一切都很好,但是如果我第一次单击,例如在第三div上,它会显示其对应的div,但不在其下,它将代替它第一个对应的div.
Everything is fine as long as i click on them in order from first to last, but if i first click, let's say on third div, it shows its corresponding div, but not beneath it, it shows it in place of the first corresponding div.
我在这里使用简单的slideToggle,确实无法理解出了什么问题.如果我将相应的div(隐藏的div)显示为可见,它们都将正确显示,因此这不是CSS错误.
I am using simple slideToggle here, and really can't understand what is wrong.If i put the corresponding divs(the hidden ones) to visible, they are all displayed correctly, so it is not a CSS error.
我可以提供代码,但我将其放在网上,只需单击方法"选项卡,您就会明白我的意思.
I can provide the code, but i put it online, just click on methods tab, and you will see what i mean.
对不起,如果我没有更好地解释它,英语不是我的母语.谢谢!
Sorry if i didn't explain it better, english is not my native language.Thanks!
推荐答案
您需要保留这些div的空间.使用visibility:hidden
和animation
,但不要使用display:none
,这不会为隐藏元素保留空间.所有内置效果功能,例如hide()
,slideToggle()
等,都会将display:none
设置为您的元素.
You need to keep space for these div's. Use visibility:hidden
and animation
but do not use display:none
which doesn't keep space for hidden element. All built-in effect functions like hide()
, slideToggle()
etc. will set display:none
to your element.
这篇关于jQuery slideToggle奇怪的行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!