Help With Widget btn-group Make current button color change
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2022 01:34 PM
I am trying to set the button section that is the current selected section to a different color so the user knows which is the active section they are working on.
How can I achieve this.
Here is my HTML
So if the user selects one of the sections then that button background should be set like the home button has a blue icon, the tab should be colored and the others still white.
Any help would be appreciated,
Thank you
<div>
<div class="btn-group btn-breadcrumb" >
<a ng-click="c.setSection1Visible()" class="btn btn-info"><i class="glyphicon glyphicon-home"></i></a>
<a ng-click="c.setSection1Visible()" class="btn btn-default">Request Info</a>
<a ng-click="c.setSection2Visible()" class="btn btn-default">Data Retrieval</a>
<a ng-click="c.setSection3Visible()" class="btn btn-default">Internal Req</a>
<a ng-click="c.setSection4Visible()" class="btn btn-default">External Req</a>
<a ng-click="c.setSection5Visible()" class="btn btn-default">Regulatory Info</a>
<a ng-click="c.setSection6Visible()" class="btn btn-default">Client Impact</a>
<a ng-click="c.setSection7Visible()" class="btn btn-default">Project Info</a>
</div>
</div>
<script>
const element = document.getElementById("btn");
element.addEventListener("click", myFunction);
function myFunction() {
btn.style.backgroundColor = 'salmon';
btn.style.color = 'white';
}
</script>
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2022 03:19 PM
Can you please try it with target psuedo Selector|
CSS :target Selector
***Mark Correct or Helpful if it helps.***
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2022 03:25 PM
Watch How To Keep :Active Css Style After Click A Button Video
***Mark Correct or Helpful if it helps.***
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2023 09:43 PM
Hi @Patricia21,
Looks like I am following your footsteps! I found that tabulation format you have in this example from another doc and now I have the same question. How can I highlight the button onclick.
Did you happen to find a resolution for this?
thanks,
Jake
