Try It Editor
Tip: Press
Ctrl/⌘ + Enter
to Run
▶ Run
Reset
Copy
Download
Code
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>jQuery UI - Tabs active option</title> <link rel="stylesheet" href="https://code.jquery.com/ui/1.13.2/themes/base/jquery-ui.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <script src="https://code.jquery.com/ui/1.13.2/jquery-ui.min.js"></script> <style> body{font-family:Arial, sans-serif; padding:20px;} #tabs{max-width:500px;margin-bottom:16px;} </style> </head> <body> <h3>Tabs opened with the "active" option</h3> <p>This widget was created with <code>active: 1</code>, so "Tab 2" opens by default.</p> <button id="jumpBtn">Jump to Tab 3 (programmatically)</button> <div id="tabs"> <ul> <li><a href="#tab-1">Tab 1</a></li> <li><a href="#tab-2">Tab 2</a></li> <li><a href="#tab-3">Tab 3</a></li> </ul> <div id="tab-1"><p>First panel content.</p></div> <div id="tab-2"><p>Second panel content.</p></div> <div id="tab-3"><p>Third panel content.</p></div> </div> <script> $(document).ready(function(){ $("#tabs").tabs({ active: 1 }); $("#jumpBtn").on("click", function(){ $("#tabs").tabs("option", "active", 2); }); }); </script> </body> </html>
Output