Selecting Deselecting Divs

Selecting Deselecting Divs

I have several divs on my page and when I click a div I would like its background to change to yellow. Then when I click on another div, I would like its background to change to yellow and would like the background of the div that was previously clicked to change back to its original color. 

I thought I can solve the problem by giving the clicked div a class called highlight. Then style the highlight class with a backround color that I need. Finally when another div is clicked, remove the highlight class from the previously clicked div and add the highlight class to the current div.

Is there a better solution than this?