aboutsummaryrefslogtreecommitdiff
path: root/assets_src/js/lib/dom.js
diff options
context:
space:
mode:
Diffstat (limited to 'assets_src/js/lib/dom.js')
-rw-r--r--assets_src/js/lib/dom.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/assets_src/js/lib/dom.js b/assets_src/js/lib/dom.js
new file mode 100644
index 0000000..33845af
--- /dev/null
+++ b/assets_src/js/lib/dom.js
@@ -0,0 +1,14 @@
1export function ready(fn) {
2 document.addEventListener('DOMContentLoaded', (e) => {
3 fn();
4 }, false);
5}
6
7export function closest(el, fn) {
8 while (el) {
9 if (fn(el)) {
10 return el;
11 }
12 el = el.parentNode
13 }
14}