Question : setting text of a dynamic dom element using javascript

I'm creating dom elements in javascript code using the document.createElement method.  I'm able to dynamically create elements but  I'm not able to set the text of a "span", "h4" and "a" elements.  I tried to use the below, but get javascript errors with the innerText.  When I remove innerText I don't get any javascript erros, any ideas?
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
	var h4 = document.createElement("h4");	
	h4.setAttribute("class", "ui-widget-header");
	h4.innerText("Trash");

        var a1 = document.createElement("a");
	a1.setAttribute("class", "ui-icon ui-icon-zoomin");
	a1.setAttribute("href", "testimages/" + images[i].firstChild.nodeValue);
	a1.innerText("View Larger");

        var span = document.createElement("span");
        span.setAttribute("class", "ui-icon ui-icon-trash");
	span.innerText("Trash");

Answer : setting text of a dynamic dom element using javascript

you could try creating a text-node and appending it as a child.. i dont think innerText is part of the dom.
...
var myText = document.createTextNode("Trash");
span.appendChild(myText);
Random Solutions  
 
programming4us programming4us