Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Help With Widget btn-group Make current button color change

Patricia21
Giga Contributor

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>

find_real_file.png

 

7 REPLIES 7

Can you please try it with target psuedo Selector|

CSS :target Selector


***Mark Correct or Helpful if it helps.***

Watch How To Keep :Active Css Style After Click A Button Video



***Mark Correct or Helpful if it helps.***

Jake Golden
Tera Expert

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