I have the following situation where I want to add a class and remove the rest of it from 1
<div class="voted rating-box color ">
</div>
This is the html where the div has 3 class when executing the function I want to remove all the classes but leaving 1 and adding the star class would look like this
<div class="voted star ">
</div>
$(".voted").removeClass().addClass('star');