in my code below i can edit row success without any error but if i need to cancel value edited in row OR get value before changed what i write to cancel edit in row in table by using jquery my code as following
@{
Layout = null;
}
$(function () {
$("#btn").click(function ()
{
var x = $("#txt1").val();
var y = $("#txt2").val();
var z = $("#mycountry").val();
$("#tb").append(" " + x + " " + y + " " + z + " ");
});
$("#tb").on("click", ".c", function () {
//$(this).parent().parent().remove();
$(this).closest('tr').remove();
});
$("#tb").on("click", ".d", function () {
var row = $(this).closest('tr').toggleClass("editing");
row.find("td").slice(0, 2).prop("contenteditable", row.hasClass("editing"));
var myselect = '
'' + '' + '' + '' + ''
'';
var dropcountry = $(this).parent().prev().prev().text;
$(this).parent().prev().prev().html(myselect);
//$('#tb').append(myselect);
// $("#tb").children().children().eq(3).children().eq(3).append("myselect");
});
$("#btndis").on('click', function () {
$("body").append("
$('#tb td:nth-child(2)').each(function () {
$("#listNames").append("" + $(this).text() + " ")
});
});
});
.editing {
background: yellow;
}
ID
Name
Country:
ID | Name | Country |

Amar GaikwadRank #8,774 · 216 reputationPosted Jul 23, 2016, 8:30 PM EDT
ahmed salahRank #2,612 · 534 reputationPosted Jul 24, 2016, 2:35 AM EDT
ahmed salahRank #2,612 · 534 reputationPosted Jul 25, 2016, 5:44 AM EDT
Amar GaikwadRank #8,774 · 216 reputationPosted Jul 26, 2016, 9:38 AM EDT
- You can declare 3 variables in JavaScript for storing the initial values when user clicks on 'Edit' button.
- When user clicks on 'Edit' button set the assign the current values from edited row to these 3 variables.
- If user clicks on 'Update' button then do not take any action.
- If user clicks on 'Cancel' button then set the values stored in variables in respective cells.
Please let me know if you need any additional details.