Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8658825
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:51:38+00:00 2026-06-12T15:51:38+00:00

I am trying to create a jquery UI nested tab dynamically on a button

  • 0

I am trying to create a jquery UI nested tab dynamically on a button click but I can only get the Main tab to work but the Nested doesn’t show properly.
(Note: I dont want to define the nested divs before but create this divs dynamically)
anyone can help?

JSFiddle Link: http://jsfiddle.net/ukalaspurkar/TqF9F/

<!DOCTYPE html>
<html>
<head>
  <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
  <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
</head>
<body style="font-size:62.5%;">

<div id="tabs">
    <ul>
    </ul>
</div>

    <input type='button' id='addTab' value='Add Main Tab & Nested Tab'>

</body>
</html>



$(function() {

    $("#addTab").click(function() {
        createNestedTabs();
    });

});


function createNestedTabs() {

    //Main Tab..Working fine..
    $("#tabs").append('<div id="mainTab">Main Tab Div</div> ');
    var tabs = $("#tabs").tabs();
    tabs.tabs('add', "#mainTab", "Main Tab");

    //Nested Tab for the above Main Tab..Not working
    $("#tabs").append('<div id="nestedTab1">Nested Tab Div</div> ');
    var nestedTabs = $("#nestedTab1").tabs();
    nestedTabs .tabs('add', "#nestedTab1", "Nested Tab 1");
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T15:51:39+00:00Added an answer on June 12, 2026 at 3:51 pm

    You’re missing some HTML structure for the second div. Even though you’re creating it dynamically you still need some of the same elements as the first one. Try something like this:

    function createNestedTabs() {
        $("#tabs").append('<div id="mainTab">Main Tab Div</div> ');
        var tabs = $("#tabs").tabs();
        tabs.tabs('add', "#mainTab", "Main Tab");
    
    
        $("#mainTab").append('<div id="nestedTab1"><ul></ul></div> ');
        $("#nestedTab1").append('<div id="nestedTabContent">Nested tab</div>');
        var nestedTabs = $("#nestedTab1").tabs();
        nestedTabs.tabs('add', "#nestedTabContent", "Nested Tab 1");
    }​
    

    I modified your fiddle to demonstrate.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to get the jQuery Tablesorter plugin to work with nested tables, where
I am trying to create a jquery questionnaire but my little jquery knowledge doesn't
I am learning JQuery and trying to create cycling text through images but I
I am trying to create a simple about page that uses JQuery click to
I'm trying to create a Hide/Show button with jQuery. When .cminus is clicked, it
I'm trying to create a jQuery Slider like this . I can't find any
I'm trying to create a jquery function that can be called both on ready
I'm trying to create a jQuery like architecture in my app but i could
im trying to create something in jquery but it just keeps bugging up. here
I'm trying to create jquery dialog, but there is no use :( here is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.