Using jQuery to edit individual table cells

前端 未结 10 1979
心在旅途
心在旅途 2020-12-13 08:14

How can I use jQuery to click on a table cell and edit its contents. There is a particular column which contains several paragraphs of data, so if possible, have a pop up wi

10条回答
  •  天命终不由人
    2020-12-13 08:49

    Try this simple solution:

    $(function () {
        $("td").dblclick(function () {
            var OriginalContent = $(this).text();
    
            var inputNewText = prompt("Enter new content for:", OriginalContent);
    
            if (inputNewText != null) {
                $(this).text(inputNewText)
            }
        });
    });
    

提交回复
热议问题