Fork me on GitHub
M J10:02:44

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>
I would like to getElementById of the "id-10822", then gets its parents "aria-hidden" value


You 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 :

(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")