Cześć 👋
Jak mogę zapisać te zmiany poprzez jQuery cookies?
jQuery(document).ready(function() {
jQuery('#customSwitch1').change(function() {
if ($(this).prop('checked'))
{
$('body').addClass('elegant-color');
$('body').removeClass('morpheus-den-gradient');
}
else
{
$('body').removeClass('elegant-color');
$('body').addClass('morpheus-den-gradient');
}
});
});To rozwiązanie (poniżej) nie działa, czyli wnioskuję, że jest niepoprawne, albo coś robię nie tak.
Cookies.set("bodyclass", "bg_save");
jQuery(document).ready(function() {
jQuery('#customSwitch1').change(function() {
if ($(this).prop('checked'))
{
$('body').addClass('elegant-color');
$('body').removeClass('morpheus-den-gradient');
}
else
{
$('body').removeClass('elegant-color');
$('body').addClass('morpheus-den-gradient');
$("body").addClass(Cookies.get("bodyclass"));
}
});
});jQuery mam podpięte, przed js-cookie.
