Search code examples
javagwthtmljsni

Access div content from JSNI native function


What I'm trying is elem.innerHtml, I've also tried elem.innerText but I'm getting an empty string as result. Could I accessing an HTMLDivElement content from inside a GWT JSNI function? I would like to get rid of abstruse UiBinder work arounds.

Thanks in advance


Solution

  • working under the assumption that the division you want to access is in the DOM and has an id, you can use

    Document.get().getElementById("id")
    

    from java, or

    $doc.getElementById(String) 
    

    from javascript :)