Created
October 9, 2016 02:21
-
-
Save derHowie/cfc71e5434a3c438edc365be903cfdc3 to your computer and use it in GitHub Desktop.
toggle class in ClojureScript
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
(defn toggle-class [id toggled-class] | |
(let [el-classList (.-classList (.getElementById js/document id))] | |
(if (.contains el-classList toggled-class) | |
(.remove el-classList toggled-class) | |
(.add el-classList toggled-class)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment