hi i have table on the form. when page load is fired i set focus to the first input[type='text']. and i post the form with ajax and if all goes right i add new row to the top of the table. and now i cant set focus to new inserted row.here is my javascript code:
$(document).keypress(function (e) {
var key_code = e.which;
if (key_code == 13) {
$.ajax({
type: "POST",
url: "AddNewPayPackage",
data: $("#AddPackPayment").serialize(),
dataType: "text/plain",
success: function (response) {
if (response == "Saved") {
$('#myTable tbody tr:first input:text').removeAttr("tabindex");
$.get('AddNewPayPackage', function (data) {
$('#myTable tbody tr:first').before("<tr>" + data + "</tr>");
});
$('.input-validation-error').removeClass('input-validation-error');
$("form :input[type='text']:first").focus();
}
else {
$("#myTable tbody tr:first").html(response);
}
}
});
}
});