I tried to create an empty table so that when the user clicks in the middle of the <td>
field a <input type="text" />
appears to type.
Follow the code:
$(function () {
$("td").click(function () {
var conteudoOriginal = $(this).text();
$(this).addClass("celulaEmEdicao");
$(this).html("<input type='text' value='" + conteudoOriginal + "' />");
$(this).children().first().focus();
$(this).children().first().keypress(function (e) {
if (e.which == 13) {
var novoConteudo = $(this).val();
$(this).parent().text(novoConteudo);
$(this).parent().removeClass("celulaEmEdicao");
$(this).parent().next();
};
});
$(this).children().first().blur(function(){
var novoConteudo = $(this).val();
$(this).parent().text(novoConteudo);
$(this).parent().removeClass("celulaEmEdicao");
$(this).parent().next();
});
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><tableborder="1" cellpadding="0" cellspacing="0" width="968" style="border-collapse:collapse;table-layout:fixed;width:734pt">
<tbody>
<tr class="item" style="text-align: center;">
<td class="cidade"></td>
<th style="text-align: center;">JAN</th>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
I would like the user to move the cursor to the next <input type="text" />
of the <td>
following at the end of the typing by means of a enter
or tab
, but I was not able to make this functionality available to the user. user.