Hello! I have been looking at JavaScript for the last time and it really seems great! I have seen how you can change properties for elements, for example, changing the value of a text box to display text in it, but is there some way to write text between html-tags? For example, if a user click on a button a javascript should be run which creates a new table with one row and one cell, placing the table somewhere between the two body tags?
Of course it is possible. The best way to do it is to create a new div in your document, assign an id to it, say my_div, then you can set then content of that division using this statement: document.getElementsById("my_div").innerHTML = your_html_string;
What about the root element, the element which contains the entire html code of the document? How can I access that element? For example, a page: <html> <head> <title> root element-test </title> </head> <body> Hello </body> </html> Code (markup): which element in the DOM will have an innerHTML-element with the value <html> <head> <title> root element-test </title> </head> <body> Hello </body> </html> Code (markup):