选项卡式导航。 Jquery 和 CSS 问题
前面讨论过的脚本问题。 这里
基本上我的html没有表现出我想要的方式。
点击: 全部 - 显示所有容器
<div class="slide">
动作冒险 - 显示
<div class="slide" title="Action Adventure">
戏剧 - 显示
<div class="slide" title="Drama">
等等...
已修复 在初始加载时,加载所有容器当前仅在首次加载时起作用。在我单击另一种流派后,然后返回“全部”,它似乎表现得很奇怪,只显示所有其他流派
此问题仍然存在 然后,我注意到在初始加载后,单击列表,它会显示下一个容器,而不是具有相同标题和文本的容器。我认为这与index();有关但我不完全确定。我需要让这该死的东西正常工作。
谢谢大家!
ps,还有其他jquery来隐藏第n个孩子。忽略它即可。
感谢您的帮助!
我需要帮助的最后一件事是当所有第一个子 ul 都可见时隐藏所有第一个子 ul。除了动作冒险类的第一个之外。
Issues with a script earlier discussed.
Here
Basically my html is not behaving the way i want it to.
Clicking:
All - Display all containers
<div class="slide">
Action Adventure - Display
<div class="slide" title="Action Adventure">
Drama - Display
<div class="slide" title="Drama">
And so on...
FIXED
On initial load, load all containers only currently works on first load. After I click anather genre, then go back to 'All' it seems to behave strangly only displaying every other
This issue remains
Then, i noticed that after initial load, clicking down the list, it is displaying the next container down instead of the one with identical title and text. I think it has to do with the index(); but im not entirely sure. I need to get this dang thing working right.
Thanks guys!
ps, there is other jquery to hide the the nth-child. just ignore it.
Thanks for all the help!
One last thing I need assistance with is hide all the first-child ul's when all are visible. Except the very first one under Action-adventure.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
此处:
工作演示
带注释的演示
这里我们使用被点击的
li
的.index()
编号- 打开一个:eq()
等于此.index()
的选项卡。看看这个表:
之前你有这个:
和每个
li
很好地打开了他各自的选项卡.slide
。但您决定添加一个元素
.all
来打开所有选项卡,但现在你看到了:
正如你所看到的,
.all
没有他特定的“兄弟”选项卡可供打开。它只需打开所有选项卡即可!但是,添加这个“额外”
li
元素后,您已将其他li
元素的索引号“移动”了 1。现在单击
li
Drama ,现在索引为 3 ,它将打开具有相同索引的选项卡。但这是包含纪录片电影的选项卡!因为它的索引号仍然是3!要解决这个新问题,您必须搜索具有此索引号但为 -1 的选项卡。
( 戏剧索引(3)-1 = 打开戏剧选项卡索引(2))
考虑到这一点,你只需
.fadeOut()
所有以前使用 jQuery:visible
选择器打开的选项卡。例如:这将防止您的脚本与所有其他
.slide
发生干扰。这是您的脚本:
您还可以使用:
$('.slide').eq(i).fadeIn(400);
看起来更漂亮! :)Here:
Working DEMO
demo with comments
Here we are using the
.index()
number of a clickedli
- to open a TAB whose:eq()
equals this.index()
.Look at this tables:
Before you had this:
And each
li
was opening nicely his respective tab.slide
.But than you decided to add an element
.all
that will open ALL your tabs,But now you have this:
As you can see
.all
has not his specific 'brother' tab to open. It just has to OPEN ALL TABS!But, adding this 'extra'
li
element you have 'moved' the index numbers of the otherli
elemnts by 1 up.Now clicking the
li
Drama , having now the index 3 it will open the TAB that has the same index. But that's the TAB containing Documentary movies! as it still has the index number 3!To fix that new issue you have to search for a tab that has THIS index number but -1.
( Drama index(3)-1 = open Drama tab index(2) )
Having that in mind you just have to
.fadeOut()
all previously opened tabs using the jQuery:visible
selector. Ex:That will prevent interfering your script with all other
.slide
.And here is your script:
You can use also:
$('.slide').eq(i).fadeIn(400);
looks prettier! :)这并不能完全回答您的问题,但请务必在执行淡出之类的操作之前停止排队的动画:
否则,单击按钮几次将导致动画一遍又一遍地运行
This doesn't completely answer your question, but be sure to stop queued animations before you do something like fade out:
otherwise, clicking on a button a couple of times will cause the animation to run over and over