+++ title = "Tabs (Using JavaScript)" template = "demo.html" +++ This example shows how to load tab contents using htmx, and to select the "active" tab using Javascript. This reduces some duplication by offloading some of the work of re-rendering the tab HTML from your application server to your clients' browsers. You may also consider [a more idiomatic approach](@/examples/tabs-hateoas.md) that follows the principle of [Hypertext As The Engine Of Application State](https://en.wikipedia.org/wiki/HATEOAS). ## Example Code The HTML below displays a list of tabs, with added HTMX to dynamically load each tab pane from the server. A simple JavaScript event handler uses the [`take` function](https://hyperscript.org/commands/take/) to switch the selected tab when the content is swapped into the DOM. ```html