JSFiddle - React, Tailwind, and code Playground

by Ersin Bilgin

HTML

<table id="tblEditavel"><tbody><tr><td>rgergerge</td></tr></tbody></table>

JavaScript

$(document).ready(function(){
    
    $('#tblEditavel tbody tr td').dblclick(function(){
        
        if($('td > input').length > 0){
            return(false);
        }   
        
        var conteudoOriginal = $(this).text();
        var novoElemento = $('<input/>', {type: 'text', value: conteudoOriginal, width: '190px', class: 'foco'});
        
        $(this).html(novoElemento.blur(function(){
            var conteudoNovo = $(this).val();
            $(this).parent().html(conteudoNovo);
        }));
        
        novoElemento.trigger("focus")
        
    });
    
});