简体   繁体   English

多个标签页内容相同

[英]Multiple tabs same content

There are 6 divs on the page: 该页面上有6个div:

ABCDEFG ABCDEFG

I want to reuse those divs to display content based on the tab. 我想重复使用这些div以基于选项卡显示内容。

For example: 例如:

Tab1 = AB Tab1 = AB

Tab2 = AC Tab2 = AC

Tab3 = ABC Tab3 = ABC

and so on... 等等...

What would be the best way to do it( jQuery? ) Any examples? 最好的方法是什么(jQuery?)任何示例?

You can change the parent of the control on tab change which you want to reuse, eg something like: 您可以在要重用的制表符更改上更改控件的父级,例如:

A.parent=Tabcontroll.tabindex[1];

Not correct syntax but you get the idea. 语法不正确,但是您可以理解。

TabTastic是一种不错的,可访问且带有体面文档的方法。

Have a DIV which encloses the entire area controlled by the tabs. 具有一个DIV,该DIV包围了选项卡控制的整个区域。 Add and remove CLASSes 'tab1', 'tab2', 'tab3' to that outer DIV based on the selected tab. 根据选定的标签,将CLASS'tab1','tab2','tab3'添加到该外部DIV并从中移除。 Have CSS rules which display the proper internal DIVs based on the enclosing CLASS. 具有CSS规则,该规则可根据随附的CLASS显示正确的内部DIV。 For example: 例如:

#A, #B, #C, #D, #E, #F {display:none}

.tab1 #A, .tab1 #B {display:block}

.tab2 #A, .tab2 #C {display:block}

.tab3 #A, .tab3 #B, .tab3 #C {display:block}

You can implement with below logic. 您可以使用以下逻辑实现。

Render 6 div and make it style="display: none;" 渲染6 div并将其设置为style="display: none;"

You can use jQuery UI tabs. 您可以使用jQuery UI选项卡。 Refer this link 引用此链接

Design your tabs as explained in jQuery UI tabs and click of tabs populate its html or data after getting from hidden divs. 按照jQuery UI选项卡中的说明设计选项卡,并在从隐藏的div获取信息后单击选项卡填充其html或数据。

For more you can check below fiddle demo prepared. 有关更多信息,请查看下面准备的小提琴演示。 Remember its only sample and the idea to implement your desired functionality 记住它的唯一示例以及实现所需功能的想法

Check this fiddle 检查这个小提琴

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM