Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


get the value of row before changing in table if cancel click

get the value of row before changing in table if cancel click

get the value of row before changing in table if cancel click

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

CODE --> script

    Layout = null;

<!DOCTYPE html>



    <meta name="viewport" content="width=device-width" />


    <script src="~/Scripts/jquery-1.10.2.js"></script>



        $(function () {

            $("#btn").click(function ()


                var x = $("#txt1").val();

                var y = $("#txt2").val();

                var z = $("#mycountry").val();

                $("#tb").append("<tr> <td>" + x + "</td> <td>" + y + "</td> <td>" + z + "</td><td> <input type='button'class='c' value='Delete'/></td><td> <input type='button' class='d' value='Edit'/></td><td><input type='button' class='e' value='Cancel'/></td></tr>");


            $("#tb").on("click", ".c", function () {




            $("#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 = '<select id="mycountr1" name="mycountry1">' +

               '<option>---select---</option>' + '<option>Egypt</option>' + '<option>qatar</option>' + '<option>saudia</option>' + '<option>emarates</option>'


              var dropcountry = $(this).parent().prev().prev().text;




                //  $("#tb").children().children().eq(3).children().eq(3).append("myselect");


            $("#btndis").on('click', function () {

                $("body").append("<ul id='listNames''></ul>");

                $('#tb td:nth-child(2)').each(function () {

                    $("#listNames").append("<li>" + $(this).text() + "</li>")








        .editing {

            background: yellow;






        ID<input type="text" id="txt1" /><br />

        Name<input type="text" id="txt2" /><br />

        Country: <select id="mycountry">






</select><br />

        <input type="button" value="add" id="btn" />

        <input type="button" value="display" id="btndis" />
















            <tbody id="tb"></tbody>





Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close