Currently, I am working on a website project that utilizes Bootstrap framework. One section of the website consists of three buttons, each linking to a different page within the site.
<div class="container-fluid filter-tag py-3">
<ul class="tag-menu">
<li><a href="<?php echo esc_attr( add_query_arg( 'tag', 'biella' ) ); ?>" class="btn"> Biella </a></li>
<li><a href="<?php echo esc_attr( add_query_arg( 'tag', 'vercelli' ) ); ?>" class="btn"> Vercelli </a></li>
<li><a href="<?php echo esc_attr( add_query_arg( 'tag', 'valsesia' ) ); ?>" class="btn"> Valsesia </a></li>
</ul>
</div>
To indicate the active state, I have applied CSS styling which changes the background-color and text color when a button is clicked. This provides visual feedback for users as they navigate through the website.
.tag-menu li a{
border:1px solid $primary;
border-radius:12px;
padding:5px;
margin-right:7px;
color:#000000;
}
.tag-menu li a:active{
border:1px solid $primary;
background-color:$primary;
border-radius:12px;
padding:5px;
margin-right:7px;
color:#ffffff;
box-shadow:none;
}
Upon testing, I noticed that the active class only appears briefly when a button is clicked before reverting back upon page load. Despite attempting various solutions found on similar issues on Stack Overflow, I have not been successful in resolving this issue with JQuery or JavaScript.
If anyone could offer guidance on how to address this problem effectively, it would be greatly appreciated. Thank you.