Well the question might seem stupid but I really can't figure it out. How can you add dynamically a html heading tag to your page using the google web toolkit.
I don't want to do this for the style of the heading as I could add any style to any label, it is because I want to use the jqueryui accordion it works with a pair of header and content panel.
How can I do this?
Yes this is kinda complicated to say the least.... Here is the easiast example I can think of:
import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.HeadingElement;
...
HeadingElement headingElement = Document.get().createHElement(1);
headingElement.setInnerText("This is a Heading1 (h1) element!");
RootPanel.get().getElement().appendChild(headingElement);
If you look at the other methods of the Document.get()....
you will find methods for creating all other HTML elements too.
Addition:
This might be even easier:
import com.google.gwt.user.client.ui.HTML;
.....
HTML headingElement= new HTML();
headingElement.setHTML("<h1>This is a Heading1 (h1) element!</h1>");
RootPanel.get().getElement().appendChild(headingElement);
You can also use HTMLPanel and specify which tag to use in the constructor:
HTMLPanel header = new HTMLPanel ("h1", "bla bla bla");
should produce
<h1>bla bla bla</h1>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With