<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script> <script> $(document).ready(function() { $('section.page-section').each(function(){ var layclass = $(this).find('.code-block .cbsc').attr('class'); $(this).addClass(layclass); }); $('a[href="#menu01"]').addClass('change-button-style'); $('.menu01-section').addClass('show-section').removeClass('hide-section'); $('section.cbsc:not(.menu01-section)').removeClass('show-section').addClass('hide-section'); $('a[href="#menu01"]').click(function(){ $('.menu01-section').addClass('show-section').removeClass('hide-section'); $('section.cbsc:not(.menu01-section)').removeClass('show-section').addClass('hide-section'); $(this).addClass('change-button-style'); $('a:not([href="#menu01"])').removeClass('change-button-style'); }); $('a[href="#menu02"]').click(function(){ $('.menu02-section').addClass('show-section').removeClass('hide-section'); $('section.cbsc:not(.menu02-section)').removeClass('show-section').addClass('hide-section'); $(this).addClass('change-button-style'); $('a:not([href="#menu02"])').removeClass('change-button-style'); }); }); </script> <style> section.page-section.hide-section { display: none !important; } section.page-section.show-section { display: block !important; } .change-button-style { background-color: #8c0741 !important; } </style>