I am looking to implement a feature where clicking on certain cells will add and switch classes, similar to a calendar schedule.
I attempted the code sample below, but it did not successfully toggle each class.
The desired outcome is to switch classes like this through clicks:
null
→classA
→classB
→classC
→null
→classA
Here is my current code snippet:
$("#our_calendar td")
.click(function() {
$(this).toggleClass('classA classB classC');
});
I intend to change the color of the cells by creating corresponding CSS styles for them.
.classA {
background-color: rgb(0,255,0);
}
.classB {
background: linear-gradient(to bottom, yellow 49%,yellow 1%, rgb(0, 255, 0) 1%,rgb(0, 255, 0) 50%);
}
.classC {
background: linear-gradient(to bottom, yellow 49%,yellow 1%, aqua 1%, aqua 50%);
}
If anyone knows how to achieve this functionality, please share your insight. Thank you!