Home > Article > Web Front-end > YUI's Tab switching implementation code_YUI.Ext related
Tab switching should not depend on HTML structure, giving designers and front-end developers maximum flexibility. Principle: A tab object is divided into a control part (trigger) and a content part (sheet). When the trigger is triggered, the corresponding sheet is displayed.
Dashu wrote a TabControl code before. After two years of use, it is still very testable, which shows that this idea was relatively in line with actual needs. I changed it to a YUI-based version, which may look clearer. First visit the test page to see the effect. The complete javascript code is here.
Note: When changing to actual code, please put the Tab class under a certain namespace and do not expose it directly to the global space.
1: Use
The following are commonly used html structures, but are not limited to this.