TabControl.removeItem

Syntax

removeItem(value);

Parameters

value. Index of the element to be removed.

Description

The removeItem method removes a tab from the component by its index.

Example

To execute the example, connect the PP.js components library and the PP.css visual styles table. Create the TabControl component and an HTML button, clicking which removes the selected tab.

<body>
<div id="tabcont1"></div>
<!--Button that removes the selected tab-->
<button onclick="tabcontrol.removeItem(tabcontrol.getSelectedIndex());">Remove selected</button>
<script type="text/javascript">
    // Create the TabControl component:
    var tabcontrol = new PP.Ui.TabControl({
            //Identifier for the div tag
            ParentNode: document.getElementById("tabcont1"),
            Width: 300,
            Height: 300,
            //Path to the folder with images:
            ImagePath: "img"
        });
    //Add tabs:
    tabcontrol.addItem(new PP.Ui.TabItem({ Position: PP.LTRB.Top, Caption: "First tab", Content: "First tab content" }));
    tabcontrol.addItem(new PP.Ui.TabItem({ Position: PP.LTRB.Top, Caption: "Second tab", Content: "Second tab content" }));
</script>
</body>

After executing the example the HTML page will contain the TabControl component, which consists of two tabs and the button named Remove Selected. Clicking the button removes the selected tab.

NOTE. The tab can be removed using the removeItem method if some content is set for the tab.

See also:

TabControl