javascriptattributesclickaddeventlistenersetattribute

How do I remove an already set attribute and replace with another in JavaScript


I added an attribute to a div I created, now I want to remove this attribute and replace with another once listen to a click event. How do I do that?

I tried using the remove attribute but I don't seem to understand why it's not working...


Solution