This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-02-26
Channels
- # babashka (5)
- # beginners (7)
- # biff (34)
- # calva (2)
- # cider (1)
- # clj-commons (1)
- # clj-yaml (4)
- # clojure (18)
- # clojure-europe (8)
- # clr (1)
- # conjure (3)
- # core-async (1)
- # data-science (1)
- # datalevin (9)
- # emacs (3)
- # helix (1)
- # honeysql (11)
- # hyperfiddle (18)
- # introduce-yourself (1)
- # music (1)
- # pathom (2)
- # polylith (2)
- # remote-jobs (1)
- # scittle (20)
- # shadow-cljs (8)
- # spacemacs (1)
- # xtdb (12)
How can I get the element by id of a div element, for example, I have:
<div aria-hidden="false">
<div id="id-10822"></div>
</div>
I would like to getElementById of the "id-10822", then gets its parents "aria-hidden" valueYou may use whichever of the browser's built-in functions you would use in Javascript. Remember the getElementById is a function on the DOM Document, which in ClojureScript can be referenced as js/document
. So you can start with (.getElementById js/document "id-10822")
👍 1
...and as a lucky CLJS user, you can also use https://google.github.io/closure-library/api/goog.dom.html :
(goog.dom/getElement "id-10822")
Oops. Missed the rest of the Q. Once you have the div, this gives you the parent:
(.-parentNode div) or (goog.dom/getParentElement div)
Once you have the parent, this gives you "aria-hidden":
(.-ariaHidden parent) or (goog.object/get parent "ariaHidden")