I have saved few data from the view to database and added it to dynamically created html table using jquery in my asp.net mvc application. The script is given below.
$(document).ready(function() {
var attributetable = [];
$("#AddAttrib").click(function(event) {
event.preventDefault();
$("#AttributeList").show();
var attribute = $("#Attribute").val();
var attributename = $("#Attribute option:selected").text();
var documentId = $("#DocumentId").val();
var instructionId = $("#InstructionId").val();
var attributevalue = $("#text1").val();
attributetable.push({
attribute: attribute,
attributevalue: attributevalue
});
var row = $("<tr></tr>");
var contents = '<tr><td>' + attribute + '</td><td>' + attributename + '</td><td>' + attributevalue + '</td><td><a id="delete" href="#">Delete</a></td></tr>';
$("#AttributeList").append(contents);
var jsonToPost = {};
jsonToPost.attribute = attribute;
jsonToPost.attributename = attributename;
jsonToPost.attributevalue = attributevalue;
jsonToPost.documentId = documentId;
jsonToPost.instructionId = instructionId;
jsonToPostString = JSON.stringify(jsonToPost);
alert(jsonToPostString);
$.post("/Instruction/CreateInstnAttribute", { data: jsonToPostString });
});
I need to delete the row when "delete" is clicked. The requirement is to delete the row on clicking the delete link. how can i achieve it? Thanks for all helps in prior.