Each one of the following if statements works perfectly as long as the other if statement isn’t present. I don’t understand why having both if statements causes the function not to work. I’ve tried so many variations but can’t figure it out. This is the code:
$("a").click(function(event){
event.preventDefault();
let lItem = document.querySelectorAll(".listing-item");
let mItem = document.querySelectorAll(".menu-item");
let destination = $(this).attr("href");
if ( $(this).parent(lItem) ) {
tlUp.tweenTo(0, {
onComplete: () => {
window.location = destination;
}
});
}
if ( $(this).parent(mItem) ) {
tlMenu.tweenTo(0, {
onComplete: () => {
window.location = destination;
}
});
}
});