I am currently using a jQuery styleswitcher to change the stylesheet upon click. Despite trying various solutions, I have been unable to find a resolution to this issue. Could someone please assist me in setting a cookie for this functionality?
Markup:
<ul class="colors-list">
<li><a title="Black" id="black" class="black" ></a></li>
<li><a title="Green" id="green" class="green" ></a></li>
<li><a title="Blue" id="blue" class="blue" ></a></li>
</ul>
jQuery
<pre><code>(function ($) {
"use strict";
var mainApp = {
main_fun: function () {
/*=====================================
THEME SWITCHER SCRIPTS
===================================*/
//THE PANEL TOGGLE FUNCTIONALITY ON CLICK
jQuery('#switch-panel').click(function () {
if (jQuery(this).hasClass('show-panel')) {
jQuery('.switcher').css({ 'left': '-50px' });
jQuery('#switch-panel').removeClass('show-panel');
jQuery('#switch-panel').addClass('hide-panel');
} else if (jQuery(this).hasClass('hide-panel')) {
jQuery('.switcher').css({ 'left': 0 });
jQuery('#switch-panel').removeClass('hide-panel');
jQuery('#switch-panel').addClass('show-panel');
}
});
$('#black').click(function () {
$('#mainCSS').attr('href', 'assets/css/style.css'); //PATH TO BLACK STYLESHEET
});
$('#blue').click(function () {
$('#mainCSS').attr('href', 'assets/css/blue.css'); //PATH TO BLUE STYLESHEET
});
$('#green').click(function () {
$('#mainCSS').attr('href', 'assets/css/green.css'); //PATH TO GREEN STYLESHEET
});
$('#red').click(function () {
$('#mainCSS').attr('href', 'assets/css/red.css'); //PATH TO RED STYLESHEET
});
},
initialization: function () {
mainApp.main_fun();
}
}
$(document).ready(function () {
mainApp.main_fun();
});
}(jQuery));