简体   繁体   中英

Use JS appendChild on a GWT Element

I'm having a surprising issue: I've created a method to underline it:

protected native String jsAppendChild(Element item)/*-{
    var div = $doc.createElement("div");
    div.innerHTML = "hey do you see me";
    item.appendChild(div);
}-*/;

calling this method on a GWT Element doesn't add the element to the DOM!?

Any explanations?

The problem is a simple typo:

div.innerHtml = "hey do you see me";

should be

div.innerHTML = "hey do you see me";

See here

@Baz是正确的,如果您熟悉jQuery,则也可以使用GQuery:

GQuery.$(item).append("<div>Ey do you see me?</div>");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM