celltext = document.createTextNode("remove"); div = document.createElement("div"); div.className = "TreeViewTextAnchor"; div.appendChild(celltext); anchor = document.createElement("a"); anchor.onclick = new Function("RemoveSelectedItem('" + String(i) + "')") anchor.appendChild(div); cell.appendChild(anchor); row.appendChild(cell); tablebody.appendChild(row);