I run a jQuery styleswitcher that change stylesheet on click.I tried some solutions but i cant find a solution for this. I dont understand how to set a cookie to this. Please anybody that can help me with this issue?
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 CALLING OF PANEL ON CLICKING PLUS BUTTON
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'); //THE STYLE SHEETS WITH THEIR PATHS
});
$('#blue').click(function () {
$('#mainCSS').attr('href', 'assets/css/blue.css'); //THE STYLE SHEETS WITH THEIR PATHS
});
$('#green').click(function () {
$('#mainCSS').attr('href', 'assets/css/green.css'); //THE STYLE SHEETS WITH THEIR PATHS
});
$('#red').click(function () {
$('#mainCSS').attr('href', 'assets/css/red.css'); //THE STYLE SHEETS WITH THEIR PATHS
});
},
initialization: function () {
mainApp.main_fun();
}
}
$(document).ready(function () {
mainApp.main_fun();
});
}(jQuery));