I create table dynamically included some data. when a user double click on each `<td>`, the `<td>` convert to `<input type='text'>`. if user clicks outside of this input, it must be saved to database.
but the problem is, if the user double clicks on the `<td>` , function triggered just for the first time and if double clicks again, it triggers on click event. 

```
<table>
  <tbody>
    <tr><td data-name="name">US</td></tr>
  </tbody>
</table>

<script>
  $(document).on('dblclick','tbody tr td', function(){
    var value = $(this).text();
    var name = $(this).attr('data-name');
    $(this).html('<input type="text" id="tmp_ed" value="'+value+'"/>');
    $(document).on('click', function(e){
       if(e.target.id !='tmp_ed'){
          var item = $('#tmp_ed').val();
          $.ajax({
            url: "update.php",
            data: item,
            success: function(d){
               alert(d);
             }
          });
        }
    });
  });
</script>

```