$(".title").click(function () {
if ($(this).parent().hasClass("is-closed")) {
$(this).parent().removeClass("is-closed");
$(this)
.parent()
.css("max-height", parseInt($(this).next().height()) + parseInt(80));
timer = window.setTimeout(() => {
$(this).parent().css("max-height", "inherit");
}, 500);
} else {
$(this).parent().addClass("is-closed");
$(this)
.parent()
.css("max-height", parseInt($(this).next().height()) + parseInt(80));
window.setTimeout(() => {
$(this).parent().css("max-height", "50px");
}, 2);
window.clearTimeout(timer);
}
});
I have an accordion menu and basically, I set max-height inherit after some time when it opened. (I do this because when resizing the browser not all content is visible. Because when minimizing the browser content has more height.)
Anyway, the code works fine. It does what I want. But in Chrome Console, I see this error:
Uncaught ReferenceError: timer is not defined
window.clearTimeout(timer);
throws the error.
Is it something I should be concerned about?