I’ve just now started with OPA and I want to parse a DOM, but I can only get elements by the id, with Dom.get_value(#an_id) for example. What if I have a layout like the one in the chat example on the tutorials:
<div class="line">
<div class="user">{x.author}:</div>
<div class="message">{x.text}</div>
</div>
How can I get the text that is in the message div? I’ve tried Dom.get_value(Dom.select_class(“line”).select_class(“message”)), but I get this error:
Error
File "chat.opa", line 29, characters 49-62, (29:49-29:62 | 714-727)
Record expression has type dom but field access expected it to have type
{ select_class: 'a; 'r.a }.
First :
Dom.get_valueonly works oninputortextareatags.In your case, you should call
Dom.get_texton yourdiv.However, if you want to get the content without wondering if you have an input/textarea or not, just use
Dom.get_contentMoreover, you can’t do :
You can do :
or