Jo: Finde den Fehler nicht

Beitrag lesen

Hallo.

function addElem(e) {  
	mainForm = document.getElementById("Mediacontainer");  
	if(e=='t'){  
		var newBlock="text";  
	}  
	if(e=='b'){  
		var newBlock="bild";  
	}  
	var newnew=document.createTextNode(newBlock);  
	mainForm.lastChild.appendChild(newnew.nodeValue);  
}

Es soll wenn addElem('t') ausgeführt wird, "text" hinten am DIV mit der ID "Mediacontainer" drangehängt werden, bei 'b' soll es "bild" sein.

Es geht nicht.

Fehlerkonsole sagt:

Fehler: uncaught exception: [Exception... "Could not convert JavaScript argument arg 0"  nsresult: "0x80570009 (NS_ERROR_XPC_BAD_CONVERT_JS)"  location: "JS frame :: skript.js :: addElem :: line 127"  data: no]

Und line 127 ist: mainForm.lastChild.appendChild(newnew.nodeValue);

Also woran liegts??
Ich komm nicht weiter.

Gruß, Jo