I´m trying to set an active tab according to the date. So if today is Tuesday, I need Tuesday to be the active tab. I´m working on wordpress, with visual composer plugin. Te JQuery that I`m working on, works fine with tabs made from scratch but I'm having trouble finding the correct class to set the "active" attribute to the tab. The website I'm trying this is http://ordernow.com.ar/home/ and I leave my js code for you to see. The part that I'm working on is the else if for todayIdx 2 cause I've worked on a tuesday. But you can copy that code to the index of the day you work. Thanks a lot.
<script>
(function($){
var today = new Date();
var todayIdx = today.getDay();
if (todayIdx === 0) {
$('li:nth-child(6)').removeClass('active');
$('li:nth-child(7)').addClass('active');
$('.block article').hide();
$('.block #do1').show();
}
else if (todayIdx === 1) {
$('li:nth-child(7)').removeClass('active');
$('li:nth-child(1)').addClass('active');
$('.block article').hide();
$('.block #lu1').show();
}
else if (todayIdx === 2) {
$('.w-tabs-item.claselunes').removeClass('active');
$('.w-tabs-item.clasemartes').addClass('active');
}
else if (todayIdx === 3) {
$('li:nth-child(2)').removeClass('active');
$('li:nth-child(3)').addClass('active');
$('.block article').hide();
$('.block #mi1').show();
}
else if (todayIdx === 4) {
$('li:nth-child(3)').removeClass('active');
$('li:nth-child(4)').addClass('active');
$('.block article').hide();
$('.block #ju1').show();
}
else if (todayIdx === 5) {
$('li:nth-child(4)').removeClass('active');
$('li:nth-child(5)').addClass('active');
$('.block article').hide();
$('.block #vi1').show();
}
else {
$('li:nth-child(5)').removeClass('active');
$('li:nth-child(6)').addClass('active');
$('.block article').hide();
$('.block #sa1').show();
}
console.log('jquery cargado con éxito');
console.log('today:', todayIdx);
})(jQuery);
</script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>