Say I have the following html:
<div class="item">one</div>
<div class="item">two</div>
<div class="item">three</div>
I would like to log the innerHTML for each element. I have tried the following:
document
|> Document.querySelectorAll(".item")
|> NodeList.toArray /* not sure if this is needed */
|> Array.map(Document.ofNode) /* not sure if this is needed */
|> Array.map(Element.innerHTML)
|> Array.iter((number) => {
Js.log(number);
});
The error is on line |> Array.map(Element.innerHTML)
And the error is:
This has type:
array(Webapi.Dom.Element.t) => array(string)
But somewhere wanted:
array(Dom.node) => 'a
How can I use the Dom.node
so that I access the innerHTML
?