1. Using the plugin Mindmup-editabletable.js
$ (' #table '). Editabletablewidget ({editor: $ (' <textarea> ')});
2.jquery Direct Processing
functionedittable_t () {$ ("Table"). On ("click", "Td:not (. Active)",function () { var$ This= $( This); var$textbox = $ ("<input>", {type: "text", Size:5, Value: $ This. addclass ("Active"). Text ()}); $ This. HTML ($textbox); $textbox. focus (); }); $("Table"). On ("Blur", "Input:text",function () { var$ This= $( This); $ This. Parent (). Removeclass ("active"). Text ($ This. Val ()); });}
function edittable_t () { $ (true); $ ("table tr TD"). each (function() { var contents = $ (this). HTML () ; $(this). HTML ($ ("<div>"). Append (contents)); }); $ (true);}
functionedittable_t () {$ ("Table TD"). Click (function(e) {if( $( This). Find (' input '). length) {return ; } varInput = $ ("<input type= ' text ' size= ' 5 '/>"). Val ($ ( This). text ()); $( This). Empty (). append (input); $( This). Find (' input '). focus (). blur (function(e) {$ ( This). Parent (' TD '). Text ($ ( This). Val ()); }); });}
$ ("Table tr TD"). On (' Blur ', "input[type= ' text ']",function(e) {$ ( This). Closest (' TD '). Text ($ ( This). Val ());}); $("Table"). On (' Click ', ' TD ',function(e) {if( $( This). Find (' input '). length) {return ; } varInput = $ ("<input type= ' text ' size= ' 5 '/>"). Val ($ ( This). text ()); $( This). Empty (). append (input); });
varz={};functiontdclicks () {varX= "", y= "";$("Table tr TD"). Click (function() {z=$( This); X= $( This). Text () | | $( This). Find ("input[type= ' text ']"). Val (); if(!x) {x=""; } $( This). HTML ("<input type= ' text ' size= ' 5 ' value= '" + x+ "'/>"); $( This). Unbind ("click"); $( This). Find ("input[type= ' text ']"). Bind ("Blur",function() {Catchme ($ ( This). Val ()); Tdclicks (); });});}functionCatchme (WHT) {$ (z). Text (wht);} Tdclicks ();
js-jquery-Convert table TD to editable text