I have developed my own jQuery Switcher and I am looking to enhance it by removing a class when clicking on a different color option. For example, if the body tag currently has the class "blue" and someone clicks on red, I want to remove the blue class and add the red class instead.
Here is the code snippet :
$("body").addClass("wide light blue");
// Custom Switcher jQuery Plugin
$(".switcher-toggle").click(function() {
$("#switcher").toggleClass("open");
});
// Change Theme Layout
$(".layout").change(function() {
var layout = $(".layout").val();
$(".wrapper").css("width",layout);
});
// Switch Theme Skins
$(".skins").change(function() {
var skin = $(".skins").val();
$("body").toggleClass(skin);
});
// Switch Theme Colors
$(".colors span").each(function() {
var data_color = $(this).attr("data-color");
$(this).click(function() {
$("body").toggleClass(data_color);
});
});
Check out the live demo here : https://jsfiddle.net/uikithemes/p18cqa5s/