The following code replaces an anchor element with an inputbox and assigns an ID to it. I'd also like to assign an onblur event to it, but can't get it working. newElement.onblur = texOnBlur(this));
All help is welcome.
function replaceElement(e) {
selectedElement = e.id
var newElement = document.createElement("input");
newElement.setAttribute("id", selectedElement);
newElement.onblur = texOnBlur(this));
newElement.value = document.getElementById(selectedElement).innerHTML;
var oldElement = document.getElementById(selectedElement);
var parentDiv = oldElement.parentNode
parentDiv.replaceChild(newElement, oldElement);
document.getElementById(selectedElement).style.width = "45px";
document.getElementById(selectedElement).style.height = "12px";
}
As you can see http://www.w3schools.com/jsref/event_onblur.asp
object.onblur=function(){myScript};
you should assign a function to .onblur
event, you assigned function result.