バニラJSを使用して要素IDでCSSプロパティを変更しようとしていますか?角4をIDで変更CSS
私は、次のような効果を達成しようとしています:
- 最初のボタンが下底にクリックされた後、上部の最初のボタンは
btn-dark
からbtn-warning
へのクラスを変更する必要があります。 - 残りのボタンは同じパターンに従う必要があります。#b2をクリックすると、#d2が
btn-dark
からbtn-warning
に変更されます。
私の現在の試行:
<div class="row">
<button *ngFor="let number of [1,2,3,4,5,6,7,8,9,10]"
type="button"
class="btn btn-dark"
id="d{{number}}"
>
</button>
</div>
<div class="row">
<button (click)="onClick($event)"
*ngFor="let number of [1,2,3,4,5,6,7,8,9,10]"
type="button"
class="btn btn-secondary"
id="b{{number}}">{{number}}
</button>
</div>
Screenshot displaying the template
ありがとう、非常に!私はそれがとても簡単であることを知らなかった。これらはAngularの私の最初のステップです。 – maghost