Forget about JQuery for a moment!
For a more elaborate explanation:
In your HTML code, you would utilize an expression to define the class
<div [ngClass]="{'blue' : isBlue }">
<p>I aim to modify the background-color of the parent div with the click of a button.
</p>
<button (click)="changeColour()" id="buy-now">BUY NOW</button>
<div>
Subsequently, your TypeScript script would manage the toggling of the value. You can incorporate expressions/class names as necessary:
export class AppComponent {
isBlue = false;
changeColour() {
this.isBlue = !this.isBlue;
console.log(this.isBlue);
}
name = 'Angular';
}
Take a look at the operational example here: