I have three approaches, here you can use both <input> or <textarea> according to your requirements.
1. Use Enter in <td> .
Using the <input> element in all <td> s,
<tr><td><input type="text"></td>....</tr>
In addition, you can resize the input to the size of its td . e.g.
input { width:100%; height:100%; }
You can optionally change the color of the input box border when it is not being edited.
2. Use the attribute contenteditable='true' . (HTML5)
However, if you want to use contenteditable='true' , you can also save the corresponding values ββin the database. You can achieve this with AJAX.
You can attach keyhandlers keyup , keydown , keypress , etc. before <td> . In addition, it is useful to use some delay () for those events when the user is continuously typing, the ajax event will not fire every time the user presses a key. eg,
$('table td').keyup(function() { clearTimeout($.data(this, 'timer')); var wait = setTimeout(saveData, 500);
3. Add <input> to <td> when clicked.
Add an input element to td when you press <td> , replace its value with the value of td . When the input is blurry, change the value of 'td to the input value. All this with JavaScript.
Bhavesh Gangani Jul 19 '15 at 12:17 2015-07-19 12:17
source share