-
-
Save jnorthrup/8809337 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class HowDoIInnerHtml implements EntryPoint { | |
@Override | |
public void onModuleLoad() { | |
Element body = Document.get().getBody(); | |
DivElement newDiv = Document.get().createDivElement(); | |
newDiv.setClassName("foo"); | |
newDiv.setInnerText("Text in the div"); | |
SpanElement newSpan = Document.get().createSpanElement(); | |
newDiv.appendChild(newSpan); | |
body.appendChild(newDiv); | |
//page shows "Text in the div" | |
Window.alert("newDiv.innerHTML? " + newDiv.getInnerHTML() + | |
"\nspan is in div? " + (newSpan.getParentElement() == newDiv)); | |
//alert shows "Text in the div <span></span>", true | |
body.setInnerHTML(""); | |
Window.alert("newDiv.innerHTML? " + newDiv.getInnerHTML() + | |
"\nspan is in div? " + (newSpan.getParentElement() == newDiv)); | |
//alert shows "", false ??? | |
body.appendChild(newDiv); | |
//page shows blank | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment