views:

42

answers:

1

Is it possible to change the element's node name in GWT? I mean something like this:

HTML h = new HTML();
h.getElement().setNodeName("mydiv")

while there is no setNodeName() method for Element.

I'd like to acquire <mydiv>some contents</mydiv> instead of default tag <div>some contents</div>

Thanks for any hints.

+2  A: 

You can't change the element node name of the HTML widget. However, you can create your own tag with Document.get().createElement("mydiv"), and use that to create a new Widget by extending Composite. However, I'm not sure why you want to do this, because adding new tags to the DOM and thereby extending HTML doesn't sound as something you should want. Setting the content in this tag isn't possible via methods like innerText because they are only available for valid tags.

Hilbrand