jQuery 工具:选项卡:将当前类添加到列表项?
Stackoverflow,
我正在通过 Jquery 工具:选项卡系统使用选项卡,似乎无法弄清楚如何将 CURRENT 类添加到不是列表中第一项的列表项,而不将该类应用于第一个项项目以及我将其添加到的任何列表项目...有人有什么想法吗?
http://flowplayer.org/tools/demos/tabs/index.html
非常感谢, 亚伦
编辑: 我没有 jQuery 工具:选项卡系统的 JavaScript/jQuery 代码...因为我从 CDN 调用它:
http://cdn.jquerytools.org/1.2.6/full/jquery.tools.min.js
但是。
这就是我在 HTML 中的内容。
<ul class="tabs">
<li><a href="#">First</a></li>
<li><a href="#">Second</a></li>
<li><a href="#">Third</a></li>
<li><a href="#">Fourth</a></li>
<li><a href="#">Fifth</a></li>
</ul>
如果我能更好地解释它,它一定是这样的: jQuery 选项卡系统将类(当前)添加到第一个选项卡,因此在我们的情况下默认为“FIRST”第一个列表项。我想要做的是将当前类添加到不同的列表项,例如“SECOND”。但这就是我的问题所在,通过 jQuery,我应该做什么来停止默认将类“current”添加到第一个列表项,所以我可以将“current”添加到另一个列表项,然后单击时在其他列表项上应用当前类别。
这有道理吗?抱歉,如果没有默认的 RAW jQuery 文件,解释起来会有点困难。
再次感谢您, 亚伦
Stackoverflow,
I am working with the Tabs via the Jquery Tools: Tabs system and cannot seem how to figure out how to add the CURRENT class to a list item that IS NOT the first item in the list without the class being applied to both the first item and whatever LIST ITEM I throw it on... Any ideas anyone?
http://flowplayer.org/tools/demos/tabs/index.html
Thank you very much,
Aaron
EDIT:
I do not have the JavaScript/jQuery Code for the jQuery Tools: Tabs System... Because I am calling it from CDN:
http://cdn.jquerytools.org/1.2.6/full/jquery.tools.min.js
But.
This is what I have in HTML.
<ul class="tabs">
<li><a href="#">First</a></li>
<li><a href="#">Second</a></li>
<li><a href="#">Third</a></li>
<li><a href="#">Fourth</a></li>
<li><a href="#">Fifth</a></li>
</ul>
If I can explain it a little more better it would have to be something like this:
The jQuery tabs system adds the class (current) to the first tab hence the first List Item by default in our case "FIRST". What I am wanting to do is add the current class to a different List Item for example "SECOND". But this is where my question comes in, what via jQuery, should I do to stop the adding of the class "current" to the first list item by default, so I may add "current" to another LIST ITEM, and then when clicked on other LIST ITEMs apply the current class.
Does that make sense? I am sorry, this is a little more difficult to explain without having the default RAW jQuery File.
Thank you again,
Aaron
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用您提供的 HTML 和 jquerytools 中的代码(如您的问题中所链接),我能够重现选项卡系统,而不会出现您遇到的问题:
JSFiddle: http://jsfiddle.net/syG2Q/
可能您需要更新到最新版本的 JQuery。
如果情况并非如此,那么也许您可以在 JSFiddle 中为我们重现您的错误(请随意使用我的作为工作例子)。
编辑
好的,我相信当我读到你的问题时我误解了你的问题。
@nav 将您链接到一些有用的文档: http://flowplayer.org/tools/ demos/tabs/anchors.html#second
根据该文档,您需要将名称添加到锚标记的
href
中,然后相应地调用它:并在页面上的 javascript 中加载:
JSFiddle:http://jsfiddle.net/syG2Q/2/
Using the HTML you have provided and the code from jquerytools (as linked to in your question), I am able to reproduce the tab system without the problem you are having:
JSFiddle: http://jsfiddle.net/syG2Q/
It may be that you need to update to the latest version of JQuery.
If this is not the case then maybe you could reproduce your bug in a JSFiddle for us (feel free to use mine as a working example).
Edit
Ok, I believe I misunderstood your question when I read it.
@nav linked you to some useful documentation: http://flowplayer.org/tools/demos/tabs/anchors.html#second
According to that documentation, you need to add a name to the
href
of your anchor tags and then call this accordingly:And in your javascript on page load:
JSFiddle: http://jsfiddle.net/syG2Q/2/
也许这就是您正在寻找的内容:
更新
根据您的编辑,我认为您可能会发现文档的这一部分很有帮助:http://flowplayer.org/tools/demos/tabs/anchors.html#second
我上面的代码仅更改它赢得的选项卡的样式实际上并没有打开您的标签页应用“当前”类。如果上面的链接对您没有用,您可以尝试以下操作:
HTML
JS
将打开第二个选项卡并为您处理所有样式等。
Maybe this is what you're looking for:
UPDATE
Based on your edit I think you may find this section of the documentation helpful: http://flowplayer.org/tools/demos/tabs/anchors.html#second
My above code only changes the style of the tabs it won't actually open the tab you applied the 'current' class to. If the link above proves to be of no use to you, you could attempt the following:
HTML
JS
Will open the second tab and handle all the styling etc for you.