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 9199459
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:32:30+00:00 2026-06-17T22:32:30+00:00

I was doing a project on HTML and jQuery recently. Thing I want to

  • 0

I was doing a project on HTML and jQuery recently. Thing I want to achieve now is to create dynamic tab with particular data on a button click.

My code for JQuery-UI tab is

$(document).ready(function() {
        var $tabs = $("#container-1").tabs();
            var tabTemplate = "<li><a href='#{href}'>#{label}</a> <span class='ui-icon ui-icon-close' role='presentation'>Remove Tab</span></li>",
            tabCounter = 2;

        $('#add_tab').click( function(){   
             var label = 'New',
            id = "tabs-" + tabCounter,
            li = $( tabTemplate.replace( /#\{href\}/g, "#" + id ).replace( /#\{label\}/g, label ) ),
            tabContentHtml = 'hi';
            tabs.find( ".ui-tabs-nav" ).append( li );
            tabs.append( "<div id='" + id + "'><p>" + tabContentHtml + "</p></div>" );
            tabs.tabs( "refresh" );
            tabCounter++;
        });
        $('#new').click( function(){
            $tabs.tabs('select', 2);
        });

    }); 

My HTML file

<div id="container-1">
    <ul>
        <li><a href="#fragment-1">List</a></li>
    </ul>

    <div id="fragment-1">

    </div>


</div>

<button id="add_tab">Add Tab</button>

When i click ‘add’ button in the console of firebug I’m get error:

ReferenceError: tabs is not defined
http://localhost:3000/
Line 38

I’m not so good with jquery-ui. How do I fix this problem?

  • 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-17T22:32:31+00:00Added an answer on June 17, 2026 at 10:32 pm

    The problem is with your script.So try this

    $(document).ready(function() {
            var tabs = $("#container-1").tabs();
                var tabCounter = 1;
    
            $('#add_tab').click( function(){
                var ul = tabs.find( "ul" );
                $( "<li><a href='#newtab'>New Tab</a></li>" ).appendTo( ul );
                $( "<div id='newtab'>Name :<input type='text'></input></div>" ).appendTo( tabs );
                tabs.tabs( "refresh" );
                tabs.tabs('select', 1);
            });
    
    
        }); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on one project where I am doing html and jquery work
http://shoes4school.project-x.me/get-involved.html Can someone please tell me what i'm doing wrong the the jQuery column
I'm doing an hobby HTML project with lots of PHP, Jquery into it. I
I am doing project in cakephp . I want to write below query in
I am trying to find a data attribute from an html input in jquery.
Hi I'm doing a little hobby project where I want to visualize a football
I am doing a project using PhoneGap + jQuery Mobile in Android. I am
I am doing a project in ckeditor.i want to add divs to the textarea
I'm doing a little project with Spring 3 MVC & jQuery I'm not sure
I am new to JSON. I was doing a project on HTML, JSON and

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.