Open In App

jQuery UI Tabs load() Method

Last Updated : 17 Mar, 2021
Improve
Improve
Like Article
Like
Save
Share
Report

jQuery UI consists of GUI widgets, visual effects, and themes implemented using HTML, CSS, and jQuery. jQuery UI is great for building UI interfaces for the webpages. jQuery UI tabs widget helps us to put some content in different tabs and allows us to switch between them. In this article, we will see how to use the load() method in jQuery UI slider. The load() method forces a reload of the indexed tab in jQuery UI.

Syntax:

$(".selector").tabs("load", index);
or
$(".selector").tabs("load", href);

Parameters: 

  • Index: It contains the index of tab which we want to open.
  • href: It contains the reference of the tab which we want to open.

Approach: First, add jQuery UI scripts needed for your project.

<link href = “https://code.jquery.com/ui/1.10.4/themes/ui-lightness/jquery-ui.css” rel = “stylesheet”>
<script src = “https://code.jquery.com/jquery-1.10.2.js”></script>
<script src = “https://code.jquery.com/ui/1.10.4/jquery-ui.js”></script>

Example 1: This example describes the implementation of the load(index) method.

HTML




<!doctype html>
<html lang="en">
  
<head>
    <meta charset="utf-8">
    <link href=
        rel="stylesheet">
    </script>
    </script>
  
    <script>
        $(function() {
            $("#gfg").tabs();
            $("#gfg").tabs("load", 0);
        });
    </script>
</head>
  
<body>
    <h1>GeeksforGeeks</h1>
    <h3>jQuery UI tabs load(index) method</h3>
  
    <div id="gfg">
        <ul>
            <li><a href="#gfg1">Tab 1</a></li>
            <li><a href="#gfg2">Tab 2</a></li>
            <li><a href="#gfg3">Tab 3</a></li>
        </ul>
  
        <div id="gfg1">
            <p>tab Number -1</p>
        </div>
  
        <div id="gfg2">
            <p>tab Number -2</p>
        </div>
        <div id="gfg3">
            <p>tab Number -3</p>
        </div>
    </div>
</body>
  
</html>


Output:

Example 2: This example describes the implementation of the load(href) method.

HTML




<!doctype html>
<html lang="en">
  
<head>
    <meta charset="utf-8">
    <link href=
        rel="stylesheet">
    </script>
    </script>
  
    <script>
        $(function() {
            $("#gfg").tabs();
            $("#gfg").tabs("load", '#gfg1');
        });
    </script>
</head>
  
<body>
    <h1>GeeksforGeeks</h1>
    <h3>jQuery UI tabs load(href) method</h3>
  
    <div id="gfg">
        <ul>
            <li><a href="#gfg1">Tab 1</a></li>
            <li><a href="#gfg2">Tab 2</a></li>
            <li><a href="#gfg3">Tab 3</a></li>
        </ul>
  
        <div id="gfg1">
            <p>tab Number -1</p>
        </div>
        <div id="gfg2">
            <p>tab Number -2</p>
        </div>
        <div id="gfg3">
            <p>tab Number -3</p>
        </div>
    </div>
</body>
  
</html>


Output:

Reference: https://api.jqueryui.com/tabs/#method-load



Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads