summaryrefslogtreecommitdiff
path: root/elm/checkhidden.js
diff options
context:
space:
mode:
Diffstat (limited to 'elm/checkhidden.js')
-rw-r--r--elm/checkhidden.js13
1 files changed, 13 insertions, 0 deletions
diff --git a/elm/checkhidden.js b/elm/checkhidden.js
new file mode 100644
index 00000000..0f76d646
--- /dev/null
+++ b/elm/checkhidden.js
@@ -0,0 +1,13 @@
+/* "checkhidden" checkbox, usage:
+ *
+ * <input type="checkbox" class="checkhidden" value="$somename">
+ *
+ * Checking that will toggle the 'hidden' class of all elements with the "$somename" class.
+ */
+document.querySelectorAll('input[type=checkbox].checkhidden').forEach(function(el) {
+ el.onclick = function() {
+ document.querySelectorAll('.'+el.value).forEach(function(el2) {
+ el2.classList.toggle('hidden', !el.checked);
+ });
+ };
+});