官术网_书友最值得收藏!

Chapter 3. Tabs and Accordions

A tab is a way of separating content, yet keeping it easy to flick from one piece to another, similar to the labels in a binder.

In a web browser's main application, the tabbed areas are completely separate web pages. In a web page, though, the information is usually related, for example various pages of a form.

An accordion is similar to a tab. It separates parts of related data so that only one piece of data is visible at a time. Throughout the chapter, when I speak about tabs, the same information can usually be applied to accordions as well.

The main visual difference between the two is that, with tabs, the handles for flicking between the various pages of data are kept either horizontally or vertically along an edge of the tabbed area. However, with accordions, the handles are more akin to chapter headings, as they are shown interleaved with the pages.

Another visual difference is that with a tab, the tabbed area immediately shifts to the newly selected area, but with an accordion, the shift is shown as an animation—the old page slides closed as the new page slides open.

Accordions are similar to "code folding" in an IDE, in which you open only the part of the data that you're interested in reading, and the rest stays closed until you need it. This makes it very easy to find the piece of data or text that you were looking for, without wading through the rest.

Implementation-wise, the two are similar—you need to display the data, place markers to indicate the page/tab changes, and then run a script to make it all work.

In this chapter, we will have a look at the following points:

  • Creating tabs and accordions using jQuery and jQuery UI
  • Managing tabs and accordions using a rich text editor and a bit of PHP
  • Using Ajax to populate your accordion and tab panels
主站蜘蛛池模板: 呼玛县| 行唐县| 自贡市| 固阳县| 洞头县| 苗栗市| 桐乡市| 澳门| 易门县| 静海县| 和田市| 定州市| 乐业县| 永安市| 潜山县| 德昌县| 图们市| 岳西县| 镇赉县| 安溪县| 宜君县| 屏东县| 迭部县| 许昌县| 布尔津县| 巩留县| 任丘市| 新干县| 浮山县| 灌云县| 扬州市| 江陵县| 田东县| 建平县| 牡丹江市| 柯坪县| 洛浦县| 巴塘县| 泗洪县| 含山县| 涟水县|