I developed two columns, both with several buttons. The goal is to click on each button, change the background color and the font color of that button.
At an early stage you have all the buttons in their natural state. By clicking on a button in the left column (A, B, C) I want only that button to change the background color and the font color, the same with the buttons in the right column.
Is there also a way that whenever you click on a button in the left column, if in the right column any button has a background color (has already been clicked) it will return to its original state?
I tried to use jquery and work with ID's and class's, but it doesn't seem the most correct way.
Can someone help me?
HTML
<div class="row">
<div class="col">
<div *ngFor="let item of Groups">
<button (click)="Change(0,item)" class="btnGrup">{{item.name}}</button>
</div>
</div>
<div class="col">
<div *ngFor="let item of Words">
<button (click)="Change(1,item)" class="btn2">{{item.name}}</button>
</div>
</div>
</div>
TS
Change(index, data) {
let self = this;
switch (index) {
case 0:
// $(".btnGrup").css({ "background-color": "#f7f7f9", "color": "#BCBCCB" });
// $(".btnGrup").css({ "background-color": "rgba(73, 129, 194, 0.1)", "color": "rgba(73, 129, 194, 1)" });
break;
case 1:
// $(".btn2").css({ "background-color": "#f7f7f9", "color": "#BCBCCB" });
// $(".btn2").css({ "background-color": "rgba(73, 129, 194, 0.1)", "color": "rgba(73, 129, 194, 1)" });
break;
}
}