btn.addEventListener('click' e=>{
const modal = e.target.closest('.modal[data-modal=cart]');
});
Порождается ли событие в элементе
Порождается ли событие кликом по элементу или упрощенно самим элементом?
function debounce(func, delay) {
let timeoutId;
return function (...args) {
clearTimeout(timeoutId);
timeoutId = setTimeout(() => {
func.apply(this, args);
}, delay);
};
}
input.addEventListener('input', debounce(e => {
fetchSuggestions(e.target.value); // This is being called on every keystroke
}, 100));