I want to select several items in
ClojureScript
, but can't! How can I get them in CLJS?
Have you tried using (.getElementsByClassName js/document "class-name")?
(.getElementsByClassName js/document "class-name")
This will return a HTMLCollection JS object, so if you want to convert it to a seq, use something like:
(array-seq (.getElementsByClassName js/document "class-name"))
Also, as a side note, if you want to make HTMLCollection ISeqable, which is a little more idiomatic, check out this other post. Why aren't NodeList / HtmlCollection seqable?
Copyright © 2021 Jogjafile Inc.
Have you tried using
(.getElementsByClassName js/document "class-name")
?This will return a HTMLCollection JS object, so if you want to convert it to a seq, use something like:
Also, as a side note, if you want to make HTMLCollection ISeqable, which is a little more idiomatic, check out this other post. Why aren't NodeList / HtmlCollection seqable?