How to remove current class added to div and add new class according to condition set?
My css contain 3 different classes:
.red { background:red }
.blue { background:blue }
.green { background:green }
at the time I want to add only one class to div id #box according to condition set by jquery variable my_color .my_color has 3 values blood,garden,sky only one set at the time.
jquery:
<script type="text/javascript">
(document).ready(function() {
if(my_color == "blood")
{ /*help me to remove current class and add .red */}
else if(my_color == "garden")
{/*help me to remove current class and add .green */ }
else if(my_color == "sky")
{/*help me to remove current class and add .blue */ }
});
</script>