onclicktabbed-view

How to switch to tabs on clicking text on other tab?


I am using tabbed panel in html,css and JS using following code. There is one table on tab2 which has Link_Text as one of cell value. How can i switch to tab3 (P) onclicking Link_Text on tab2?

 <!doctype html>
    <html lang="en">
    <head>
      <meta charset="utf-8">
      <title>jQuery UI Tabs - Default functionality</title>
      <link rel="stylesheet" href="https://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
      <script src="https://code.jquery.com/jquery-1.10.2.js"></script>
      <script src="https://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
      <link rel="stylesheet" href="/resources/demos/style.css">
      <style>
      #tabs{

}

#vartabs .ui-widget-header {
  background-color: white;
  background-image: none;
  border-top: none;
  border-right: none;
  border-left: none;
}

#vartabs .ui-widget-content {
  background-color: white;
  background-image: none;

}

#vartabs .ui-corner-top,#tabs .ui-corner-bottom,#tabs .ui-corner-all{
  border-top-left-radius: 0px;
  border-top-right-radius: 0px;
  border-bottom-left-radius: 0px;
  border-bottom-right-radius: 0px;
}



#vartabs .ui-state-default,
#vartabs .ui-state-default a {
  background-color: lightgray;
  text-align: center;
}

#vartabs .ui-state-default a {
  width: 60px;
}


#vartabs .ui-tabs-active,
#vartabs .ui-tabs-active a {
  background-color: darkgray;
  text-align: center;

}
      </style>
      <script>
      $(function() {
        $( "#vartabs" ).tabs();
      });
      </script>
    </head>
    <body>

    <div id="vartabs">
      <ul>
        <li><a href="#tabs-1">S</a></li>
        <li><a href="#tabs-2">T</a></li>
        <li><a href="#tabs-3">P</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">
        <table id="summary-table"  cellpadding="0" cellspacing="0"  style="width:100%;">
         <tr bgcolor="silver"  valign="top">
         <th width="60" height="40" ><font color="white">Col1</font></th>
         <th width="50" height="40" ><font color="white">Count</font></th>
        </tr>
         <tr><td><a HREF="javascript::void()"><font color="black">Link_Text</font></a></td><td>3</td></tr>
     </table>
      </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>
  </body>
</html>

[image][1]

https://i.sstatic.net/wkp5v.png


Solution

  • This may do.

    Use the same href as the main tabs

      <tr>
        <td><a href="#tabs-3" id="movetotab3">Link_Text</a></td>
        <td>3</td>
      </tr>
    

    JQuery

    $("#movetotab3").click(function() {
      $("#vartabs").tabs("option", "active", 2);
    });