JQuery tab to go to another tab from the contents of the tab

I am using jquery tab plugin.

I would like to link content inside tab 1 to go to tab 3 instead of clicking tab 3 to go to it. How to do it?

@redsquare ... So, I changed it based on your assumption that I can get all tabs to interact with each other. This change works, thanks again, so I think I'm wondering if there is a better way to write this or is this the best way?

Demo with the latest changes: http://jsbin.com/etoku3/

<script type="text/javascript"> 
    $(document).ready(function() {
        var $tabs = $("#container-1").tabs();
          $('a.tab1').click(function(){$tabs.tabs('select', 0);});
          $('a.tab2').click(function(){$tabs.tabs('select', 1);});
          $('a.tab3').click(function(){$tabs.tabs('select', 2);});
          $('a.tab4').click(function(){$tabs.tabs('select', 3);});
          $('a.tab5').click(function(){$tabs.tabs('select', 4);});
    });
</script>
+3
source share
5 answers

$('#anchor').click( function(){

  $('#tabs').tabs( "select" , 2 )

});

+6
$('#tabs').tabs({ selected: "#tabs-1" });
+1

, :

<script lang="text/javascript">
$('.tablink').live( 'click', function(){
  $('#container-1').tabs('select', $(this).attr('rel'));
});
</script>

:

<span class="tablink" rel="2">Link to tab 2</span>

<a href="" class="tablink" rel="2">Link to tab 2</a>
0

:

$(document).ready(function() {
$('a.directTab').click( function(){
    var tabWanted = $(this).attr('rel').split('-')[1];
    $('#container-1').tabs( "select" , tabWanted);
    });
});

"click", "live".

"rel" :

<a class="directTab" rel="fragment-3">want this text</a> to link to tab 3 

:

<a onclick="$('#container-1').tabs('select', 2);">want this text</a> to link to tab 3 
0
$("#your button or what uou want to clivk").live('click',function()
    {

         $('#tabs').tabs({ selected: "#tabs-1" });
    });

, 1. # tabs-2 # tabs-3. .

0

Source: https://habr.com/ru/post/1747449/


All Articles