Any good articles for managing DOM elements cleanly?

Hi just want to ask if anyone has suggestions for good articles for adding/removing dom elements cleanly?

I am trying to create a 2 player dice game where 2 players roll a dice to see whos dice have a higher value after which the score is tracked.

I managed to create the basic functionality, but realize its difficult to manage the dom elements on my page especially when i refresh the timer when the user wants to “play again”.

Its messy because i have to remove the content whenever the user click “play again” i have to create new dom nodes each time and add css classes to the nodes. Which is alot of messy code when creating dom elements. Any suggestions is much appreciated