I use following code to dynamically add rows to my ASP.NET table. I create a span, then fill it with an html textbox code to create some textboxes in my row, now I'm going to attach some functions to my textbox events, for instant blur or keypress event:
var TR = document.createElement('tr');
TR.style.textAlign = 'center';
//mission end date
var TD = document.createElement('td');
var span = document.createElement("span");
span.innerHTML = "<input maxlength='5' type='text' width='50px' style='width:50px;' value=''/>";
TD.appendChild(span);
TR.appendChild(TD);
.......
TR.appendChild(TD);
document.getElementById('<%=tblData.ClientID %>').appendChild(TR);
I've create some other javascript functions that I'd like to attach them to these dynamically created textbox events, for instance:
function onBlur(){
.....
}
how can I attach onBlur to onblur event of these dynamically created objects? thanks
on.var myInput = document.createElement("input"); myInput.addEventListener(...); mySpan.appendChild(myInput);