Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Easy responsive tabs custom tab activate

Tags:

jquery

tabs

I'm using Easy Responsive tab LINK.. Here 1st tab is active on page load.. but i want to change my active tab to something else other than 1st tab.. I have following code:

HTML:

<div id="demoTab">          
        <ul class="resp-tabs-list">
            <li> .... </li>
            <li> .... </li>
            <li> .... </li>
        </ul> 

        <div class="resp-tabs-container">                                                        
            <div> ....... </div>
            <div> ....... </div>
            <div> ....... </div>
        </div>
    </div>  

Here is my demo page. i want to change the order of activated to 2nd tab. Is it posiible?

like image 273
G.L.P Avatar asked Mar 27 '26 05:03

G.L.P


2 Answers

Probably not the correct way of doing this. I just send a click to that tab.

$('h2[aria-controls="tab_item-1"]').click();

demo: http://jsfiddle.net/HZ3F4/2/

like image 106
Fabricator Avatar answered Mar 28 '26 21:03

Fabricator


You can do it dynamically like this

<ul class="resp-tabs-list">
  <li><a href="#tab1">Responsive Tab-1</a></li>
  <li><a href="#tab2">Responsive Tab-2</a></li>
  <li><a href="#tab3">Responsive Tab-3</a></li>
</ul>

Then we need to get the hash from the url and apply the correct class:

JavaScript

var hash = '#tab1',
    lis = $("ul.resp-tabs-list > li");
lis.removeClass("resp-tab-active");
$("a[href='" + hash + "']").addClass("resp-tab-active");

Js Demo: http://jsfiddle.net/HZ3F4/5/

like image 45
Sid Avatar answered Mar 28 '26 21:03

Sid



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!