I've been attempting to merge two if functions together but I keep encountering errors. Despite trying different methods, I have not been successful in combining them.
My goal is to check if the body has a specific class and if it does, I want to uncheck a checkbox.
The two functions I tried to combine are:
if (document.body.classList.contains('thatClass')) {
// do some stuff
}
$(function() {
$(document).on("click", function(e) {
if ($(e.target).is(".main-nav-slideout") === false) {
$("#main-nav-toggle").prop("checked", false);
}
});
});
This is my attempt at combining the snippets:
$(function() {
$(document).on("click", function(e) {
if (document.body.classList.contains('thatClass') && $(e.target).is('.main-nav-slideout') === false) {
$('#main-nav-toggle').prop('checked', false);
}
});
});