Skip to content

Instantly share code, notes, and snippets.

@derHowie
Created October 9, 2016 02:21
Show Gist options
  • Save derHowie/cfc71e5434a3c438edc365be903cfdc3 to your computer and use it in GitHub Desktop.
Save derHowie/cfc71e5434a3c438edc365be903cfdc3 to your computer and use it in GitHub Desktop.
toggle class in ClojureScript
(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