Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
// true が dark mode
// false が normal mode
function getMode(type) {
const $body = $('body');
// typeの引数でonとoffを判別
const check = type ? 'on' : 'off';
type ? $body.addClass('dark') : $body.addClass('light');
type ? $body.removeClass('light') : $body.removeClass('dark');
$('input[name="view-mode"]').prop('checked', type);
$.cookie(type, check, { expires: 365, path:'/'});
// trueでdark mode : falseでnormal modeで切替
<script src=""></script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment