I have two functions that are nearly identical, but one uses a parameter. I was able to change the first one to work properly by simply adding event
as the function parameter.
How would I change the second function to work properly?
function handleBlur(event) {
const list = event.currentTarget.closest("#nav ul");
if (!event.relatedTarget || !list.contains(event.relatedTarget)) {
closeNav();
}
}
function handleDropdownBlur(btn) {
const list = event.currentTarget.closest("#nav ul");
if (!event.relatedTarget || !list.contains(event.relatedTarget)) {
closeDropdown(btn);
}
}
I tried adding event
as both a first and second parameter, but this breaks the functionality. I’m sure the solution is simple and I’m not thinking it through.
New contributor
garrett is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1