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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:35:10+00:00 2026-05-23T21:35:10+00:00

I am using jquery to create tabs on my GUI. My question is, I

  • 0

I am using jquery to create tabs on my GUI. My question is, I want to execute a function upon clicking on one of the tabs. I found the following info from the jquery site. I am new to jquery, however, and I can’t understand what “.selector” means. How can I identify a specific tab’s name? I only have an id for the whole tab set. Also, there are two segments of code from the jquery website. Can I choose to use either one? Thanks!

Directly from the jquery UI website:

This event is triggered when clicking a tab.

Code examples
Supply a callback function to handle the select event as an init option.
$( ".selector" ).tabs({
   select: function(event, ui) { ... }
});
Bind to the select event by type: tabsselect.
$( ".selector" ).bind( "tabsselect", function(event, ui) {
  ...
});
  • 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-05-23T21:35:11+00:00Added an answer on May 23, 2026 at 9:35 pm

    First, a selector is basically some way to select a DOM element. The basic selectors follow CSS and regular JavaScript Format. # for id and . for class

    So in jQuery, to select a div with the id of “my-div” you would do this:

    $('#my-div')
    

    This grabs the jQuery node, with which, you can modify the node pretty much however you desire. Read about selectors more in detail in the jQuery documentation.

    Now, for your tab question…you probably want the “show” event, not “select” so that you can catch the tab you are entering. The following example will set up a couple tabs, then alert the index of which tab you just clicked on.

    HTML

    <div class="demo">
    
        <div id="tabs">
            <ul>
                <li><a href="#tabs-1">Nunc tincidunt</a></li>
                <li><a href="#tabs-2">Proin dolor</a></li>
                <li><a href="#tabs-3">Aenean lacinia</a></li>
            </ul>
            <div id="tabs-1">
                <p>Proin elit arcu, rutrum commodo, vehicula tempus, commodo a, risus. Curabitur nec arcu. Donec sollicitudin mi sit amet mauris. Nam elementum quam ullamcorper ante. Etiam aliquet massa et lorem. Mauris dapibus lacus auctor risus. Aenean tempor ullamcorper leo. Vivamus sed magna quis ligula eleifend adipiscing. Duis orci. Aliquam sodales tortor vitae ipsum. Aliquam nulla. Duis aliquam molestie erat. Ut et mauris vel pede varius sollicitudin. Sed ut dolor nec orci tincidunt interdum. Phasellus ipsum. Nunc tristique tempus lectus.</p>
            </div>
            <div id="tabs-2">
                <p>Morbi tincidunt, dui sit amet facilisis feugiat, odio metus gravida ante, ut pharetra massa metus id nunc. Duis scelerisque molestie turpis. Sed fringilla, massa eget luctus malesuada, metus eros molestie lectus, ut tempus eros massa ut dolor. Aenean aliquet fringilla sem. Suspendisse sed ligula in ligula suscipit aliquam. Praesent in eros vestibulum mi adipiscing adipiscing. Morbi facilisis. Curabitur ornare consequat nunc. Aenean vel metus. Ut posuere viverra nulla. Aliquam erat volutpat. Pellentesque convallis. Maecenas feugiat, tellus pellentesque pretium posuere, felis lorem euismod felis, eu ornare leo nisi vel felis. Mauris consectetur tortor et purus.</p>
            </div>
            <div id="tabs-3">
                <p>Mauris eleifend est et turpis. Duis id erat. Suspendisse potenti. Aliquam vulputate, pede vel vehicula accumsan, mi neque rutrum erat, eu congue orci lorem eget lorem. Vestibulum non ante. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Fusce sodales. Quisque eu urna vel enim commodo pellentesque. Praesent eu risus hendrerit ligula tempus pretium. Curabitur lorem enim, pretium nec, feugiat nec, luctus a, lacus.</p>
                <p>Duis cursus. Maecenas ligula eros, blandit nec, pharetra at, semper at, magna. Nullam ac lacus. Nulla facilisi. Praesent viverra justo vitae neque. Praesent blandit adipiscing velit. Suspendisse potenti. Donec mattis, pede vel pharetra blandit, magna ligula faucibus eros, id euismod lacus dolor eget odio. Nam scelerisque. Donec non libero sed nulla mattis commodo. Ut sagittis. Donec nisi lectus, feugiat porttitor, tempor ac, tempor vitae, pede. Aenean vehicula velit eu tellus interdum rutrum. Maecenas commodo. Pellentesque nec elit. Fusce in lacus. Vivamus a libero vitae lectus hendrerit hendrerit.</p>
            </div>
        </div>
    
    </div><!-- End demo -->
    

    JavaScript

    $(function() {
        $( "#tabs" ).tabs({
            show : function(event,ui) {
                alert($(this).tabs('option','selected'));
            }
        });
    });
    

    To explain the demo…You select the DOM element with id “tabs” then apply the jQuery UI plugin “tabs” to it. This modifies the HTML markup to be aesthetically pleasing, as well as provides you with an event system to give you flexibility and control over your UI. The “show” option is a callback function that should be triggered whenever a new tab is shown. Inside the callback, we use the jQuery UI API to select the tabs again (through this though) and then grab the index of the selected tab. Then of course, we alert that.

    Hope this helps you out, and good luck.

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

Sidebar

Related Questions

I'm using jQuery to create a load of tabs for a web application. I've
I have created an interface using jQuery UI Tabs, however one of my requirements
I want to create multilevel accordion Navigation using jQuery , I tried using this
I'am maintaining a GUI built using JQuery. In one part of the GUI, multiple
I'm using jquery to create tabs, which works fine by adding a class=current to
I'm using jquery.ui.tabs to create a carousel. On the same page is a superfish
I'm attempting to following the tutorials found here: http://www.ifadey.com/2010/06/crud-using-jquery-and-codeigniter/ My code is updated to
I have a form to 'create a tag'. Using the jQuery code below. $(#createtag).submit(function()
I am using jQuery to create tabs. I put the javascript code in a
I have one question regarding using JQuery UI tab control in the asp.net mvc

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.