We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No description provided.
The text was updated successfully, but these errors were encountered:
function addEventListener(element, type, fn, selector) { if (!selector) { element.addEventListener(type, fn) } else { element.addEventListener(type, function (event) { const target = event.target if (target.matches(selector)) { fn.call(target, event) } }) } }
Sorry, something went wrong.
function addEventListener(element, type, fn, selector) { // 检查元素、类型和回调函数是否存在 if (!element || !type || !fn) { return; } // 如果没有选择器,则直接添加事件监听器 if (!selector) { element.addEventListener(type, fn); return; } // 添加带有事件代理的监听器 element.addEventListener(type, function (event) { let targets = Array.from(element.querySelectorAll(selector)); if (targets.includes(event.target)) { fn.call(event.target, event); } }); }
No branches or pull requests
No description provided.
The text was updated successfully, but these errors were encountered: