Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(function () {
- // Use a delegated event handler as the inputs are dynamic
- $('#table').on('focusout', 'td input', function () {
- var $input = $(this);
- var $td = $input.closest('td');
- var content = $input.val();
- $td.html(content == "" ? "..." : content);
- }).on('click', 'td', function () {
- var $td = $(this)
- var content = $td.text();
- if (content == '...') {
- content = "";
- }
- $td.html('<input type="text" value="' + content + '" size="8" />');
- // Focus on the new input
- $('input:first', $td).focus();
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement