11 lines
No EOL
305 B
JavaScript
11 lines
No EOL
305 B
JavaScript
class MouseHandler {
|
|
onClick(selector, callback) {
|
|
let elements = document.querySelectorAll(selector);
|
|
elements.forEach((element) => {
|
|
element.onclick = (event) => {
|
|
event.preventDefault();
|
|
callback(event);
|
|
};
|
|
});
|
|
}
|
|
} |