• Tab1
  • Tab2
  • ...">
    Geek Answers Handbook

    Rename jQuery UI tab with jQuery

    I have 3 tabs:

    <div id="tabs"> <ul> <li><a href="#tabs-1">Tab1</a></li> <li><a href="#tabs-2">Tab2</a></li> <li><a href="#tabs-3">Tab3</a></li> </ul> <div id="tabs-1"></div> <div id="tabs-2"></div> <div id="tabs-3"></div> </div> 

    with this jQuery

     <script type="text/javascript"> $(document).ready(function () { var $tabs = $("#tabs").tabs({ select: function (e, ui) { } }); }); </script> 

    I would like, when performing some operation on the first and third tabs, the label of the second tab changes its name from "Tab2" to "Other text"

    I tried several ways to find on Google, but any work.

    Thanks,

    +4
    jquery jquery-ui
    Kris-i May 29 '11 at 21:24
    source share
    5 answers

    You can simply run the following code and it will change the text for the second tab.

     $('#tabs ul:first li:eq(1) a').text("Other text"); 

    Example (click the button on the third tab)

    +5
    Niklas May 29, '11 at 21:30
    source share

    Alternatively, for anyone who wants to change the text of a specific tab, "# tabs-2" in this case:

     $('#tabs [aria-controls=tabs-2] a span').text("New Label") 

    Please note that this depends on the current formatting of jquery-ui tabs and may need to be changed if the template changes in future versions.

    +2
    Digicrat Jan 24 '13 at 19:39
    source share
     $('#tabs ul li:nth-child(2) a').text('Other text'); 
    +1
    Farshid zaker May 29 '11 at 9:33 pm
    source share

    For anyone interested in changing bookmark text :

    $('#tabs .ui-tabs-selected a').text("New Title");

    +1
    Fasttrack Nov 15 '12 at 16:41
    source share

    I found another solution if you do not want to use indexes in case they are dynamic.

     $('#tabs a[href=#idoftab]').text("New Title"); 
    +1
    Ericwc Jul 08 '13 at 16:04
    source share

    More articles:

    • C ++ / bug check - c ++
    • How to list IDE forms from an IDE expert delphi - delphi
    • How can I listen every time a div changes position using jQuery? - javascript
    • String concatenation not working properly - java
    • Resizing inline user controls in a C # panel - c #
    • C ++ Platform Compatibility - c ++
    • order a list from the `snd` tuple in this list: - list
    • Show UITableView Overflow? - objective-c
    • Very small javascript not working on php page - javascript
    • python web environment for ERP development - python

    All Articles

    Geek Answers | 2019