javascript - Activate tab based on day of the week -
i have searched forum related threads, solution came across not work.
i use bootstrap display tabgroup 2 tabs. need tab 1 automatically active monday friday , tab #2 active saturday sunday.
here's html:
<ul class="cat_filter nav nav-tabs right" role="tablist"> <li role="presentation" class="active"><a href="#tab1" aria-controls="tab1" role="tab" data-toggle="tab">tab #1</a></li> <li role="presentation"><a href="#tab2" aria-controls="tab2" role="tab" data-toggle="tab">tab #2</a></li> </ul> <div class="tab-content"> <div id="tab1" role="tabpanel" class="tab-pane fade in active woocommerce">some content</div> <div id="tab2" role="tabpanel" class="tab-pane fade woocommerce">some content</div> </div>
i have tried following threads don't work me: weekday jquery ui tabs open on current day load correct day of week inside accordion gallery
please try following :
<?php if(date('l') == 'saturday' || date('l') == 'sunday'){ //l smallcase l not number 1 $day = 'tab2'; }else{ $day = 'tab1'; } ?> <ul class="cat_filter nav nav-tabs right" role="tablist"> <li role="presentation" class="<?php if($day == 'tab1'){echo 'active';}?>"><a href="#tab1" aria-controls="tab1" role="tab" data-toggle="tab">tab #1</a></li> <li role="presentation" class="<?php if($day == 'tab2'){echo 'active';}?>"><a href="#tab2" aria-controls="tab2" role="tab" data-toggle="tab">tab #2</a></li> </ul> <div class="tab-content"> <div id="tab1" role="tabpanel" class="tab-pane fade in active woocommerce">some content</div> <div id="tab2" role="tabpanel" class="tab-pane fade woocommerce">some content</div> </div>
Comments
Post a Comment