Created
June 8, 2022 06:46
-
-
Save goiblas/01fa094ea6c090bda8ba0fcd356cfa82 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function $(selector) { | |
const element = typeof selector === 'string' | |
? document.querySelector(selector) | |
: selector | |
return { | |
addClass(className) { | |
element.classList.add(className) | |
return this | |
}, | |
removeClass(className) { | |
element.classList.remove(className) | |
return this | |
}, | |
attr(name, value) { | |
element.setAttribute(name, value) | |
return this | |
}, | |
on(event, callback) { | |
element.addEventListener(event, callback) | |
return this | |
} | |
} | |
} | |
$(".button").on("click", function() { | |
$(this).addClass("active").attr("disabled", true) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment