December 28, 2024
1 min read
HTML Code
<ul class="tab_menu">
    <li data-cat="tab1" class="active">tab1</li>
    <li data-cat="tab2">tab2</li>
    <li data-cat="tab3">tab3</li>
</ul>
<div class="tab_content">
    <div class="tab_content_item tab1 active">
        Tab content 1
    </div>
    <div class="tab_content_item tab2">
        Tab content 2
    </div>
    <div class="tab_content_item tab3">
        Tab content 3
    </div>
</div>
CSS code
.tab_content_item {
    display: none;
}

.tab_content_item.active {
    display: block;
}

ul.tab_menu {
    list-style: none;
    text-align: center;
}

ul.tab_menu li {
    display: inline-block;
    padding: 5px 10px;
}

ul.tab_menu li.active {
    color: #11c540;
}
jQuery code
$('ul.tab_menu li').click(function (e) {
    e.preventDefault();
    let current_cat = $(this).data('cat');
    //menu active
    let tab_menu = $(this).siblings();
    $(tab_menu).not($(this)).removeClass('active');
    $(this).addClass('active');
    // content acive 
    let tab_content = $(this).parent().next().children();
    $(tab_content).not('.' + current_cat).removeClass('active');
    $('.' + current_cat).addClass('active');
});

Leave a Reply

Your email address will not be published. Required fields are marked *

Add an additional custom checkbox in the WooCommerce checkout

Add an additional custom checkbox after the terms and conditions in WooCommerce checkout we can use WooCommerce

Sequential Fading jQuery Text Animation

This code animates text using jQuery, creating a seamless, captivating effect with elegant fades, enhancing user engagement and enriching web design.

How to Add Quantity Plus Minus Buttons to WooCommerce Checkout Page

Learn how to add quantity plus minus buttons to your WooCommerce checkout page with this free step-by-step guide. Improve user experience and reduce cart abandonment with working code examples. No plugins needed!

WordPress category or taxonomy list

WordPress custom taxonomy term list with function and loop. show taxonomy team on wp query loop

Web Development Project in mind?

if you looking for a web developer for paid contribution to your project I am available for work.

Mukto
Mukto

Click the button below to chat with me.