Need help)
Need help)
Hi. Whats up? I an mewbie and just cant understand how to finish my work. I need to create input by touble clicking on td and after "enter" save a changed. So all is ok, but after pressing enter, all tds being chaged. so how can i change only one?
- <!DOCTYPE html>
- <html>
- <head>
- <title></title>
- <style type="text/css">
- .ta{border: 2px solid black;
- border-collapse: collapse;}
- tr td {border: 2px solid black;
- border-collapse: collapse; width: 100px;
- height: 20px;}
- </style>
- </head>
- <body>
- <table class="ta">
- <tr class="tr1">
- <td > Name: </td>
- <td class="td1" > Vito </td>
- </tr>
- <tr class="tr1">
- <td > Surname: </td>
- <td class="td1"> Scaletta </td>
- </tr>
- <tr class="tr1">
- <td > Age: </td>
- <td class="td1"> 21 </td>
- </tr>
- </table>
- </body>
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
- <!-- <script src="js/script.js"></script> -->
- <script src="js/script1.js"></script>
- </html>
- // now starts jq code))
- $(document).ready(function(){
- $(".td1").dblclick(function(){
- var po=$(this).html()
- $(this).html("")
- $(this).append("<input class='i1'>")
- var inp=$(this).val()
- // $(this).empty()
- // $(this).html(inp)
- // $(".i1").val(po)
-
- })
- $("body").change(function(){
- // alert("The text has been changed.")
- var p = $(".ta").find("input").val()
- $(".td1").each(function(){
-
- $(this).html(p)
- })
- })
- })