I'm trying to change the title attribute inside an tag when clicked. If you click it again the title attribute should change it back to its initial state and so it goes. I can make the change of the title happen, but I'm having trouble making it go back to its initial state when clicked again. Here's the code:
HTML
<a title="1" id="initial" role="button" (click)="magic()">
<p>test</p>
</a>
TS
magic(): void {
document.getElementById("initial")?.setAttribute("title", "2");
}