jQuery UI Tabs active Option - GeeksforGeeks

08 Feb, 2021
jQuery UI consists of GUI widgets, visual effects, and themes implemented using jQuery, CSS, and HTML. 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 allow us to switch between them. In this article we will see how to use active option in jQuery UI slider.The active option specifies the current active tab in jQuery UI tabs. By default, value is 0.
Syntax:
$( ".selector" ).tabs(
   { active: 1 }
);
Parameters:
boolean: if set to false will collapse all the panels. If set to true 0th index tab will be active.
number: The zero-based index of the panel that is active.
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:
HTML
<!doctype html><html lang="en">  <head>    <meta charset="utf-8">      <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>      <script>        $(function () {            $("#gfg").tabs({                active: 2            });        });    </script></head>  <body>    <h1>GeeksforGeeks</h1>    <h3>jQuery UI tabs active option</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:
HTML
<!doctype html><html lang="en">  <head>    <meta charset="utf-8">      <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>      <script>        $(function () {            $("#gfg").tabs({                active: false            });        });    </script></head>  <body>    <h1>GeeksforGeeks</h1>    <h3>jQuery UI tabs active option</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:
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
jQuery-UI
HTML
JQuery
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
How to set the default value for an HTML <select> element ?
How to update Node.js and NPM to next version ?
How to set input type date in dd-mm-yyyy format using HTML ?
JQuery | Set the value of an input text field
Form validation using jQuery
How to change selected value of a drop-down list using jQuery?
How to change the background color after clicking the button in JavaScript ?
How to add options to a select element using jQuery?