The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

I don't recommend using innerHTML to add anything but plain text (no html tags), but as you can tell, my example does just that, and this particular example works in IE 6 and Firefox. The problem with innerHTML is it isn't reliable when adding lots of complex markup. So what are you supposed to do to add lots of complex markup? A combination of createElement and appendChild like in my addElementToTheEnd example. You would keep doing that until you've built your whole structure. You can set element properties like I did with x.style.color

If you want to append to a certain part of the page, then it's best to put an empty element where you want it in the original markup of the page. So if you had a div element somewhere in the page, you'd get a reference to it using something like

yourObj = document.getElementById('yourobjID');

Then append to it like

var x = document.createTextNode('test');
yourObj.appendChild(x);

You might notice the append technique will keep adding on top of what's already in there. That's why if you're going to add just some text to an element, you'd be better off using innerHTML. Then you don't have to worry about using the DOM to remove the existing nodes.

whoosh, thanks torunforever (big help )
Is there a way to not put it at the end? - what i mean is, divs are useful, but can I make it without divs?

One other question too, if i use the div strategy, and I put a div then I make it so that it posts a var, then later when you do an onmouseover on something, it changes the var wich changes the message, or will the message stay the same?

replace instead of append

Because you said you wanted to create text, torunforever showed an example using appendChild. To replace text use replaceChild. If you do some searching for - DOM - , you will discover how useful it is.