I am new to mvc and jquery,
I have created one table with jquery and I am adding a button on each row. I need to call one function on the button click with argument.
My code is given bellow
function loadData(data) {
var tab = $('<table class="myTable"></table>');
var thead = $('<thead></thead>');
thead.append('<th>Id</th><th></th>');
thead.append('<th>Username</th>');
tab.append(thead);
$.each(data, function (i, val) {
var trow = $('<tr></tr>');
trow.append('<td>' + val.empID + '</td>');
trow.append('<td>' +"" + '</td>');
trow.append('<td>' + val.empName + '</td>');
trow.append('<td><input type="button" value="Edit" onclick="Details(" ' + val.empID + ');" /></td>');
tab.append(trow);
});
$("tr:odd", tab).css('background-color', '#C4C4C4');
$("#AllEmployees").html(tab);
};
and my function is:
function Details(k) {
alert("Failed! Please try again.");
};
Here both functions are inside the document.ready method.
But the function call is not working.