Neil's answer is probably the best approach. However, if you want to replace the record with a text field, you can use jQuery replaceWith () (the answer suggested in patrick_dw is now deleted), but you should avoid using events like keyup.
I recently wrote a plug-in that will handle text input much better than keypress , keyup and keydown . The HTML5 oninput designed to handle all kinds of text input, such as insert, drag and drop, spelling correction, etc. My plugin makes this event a cross browser.
$('.info').input(function() { var count = $(this).val().length; if (count > 10) { $(this).replaceWith('<textarea>', {value: this.value}); } });
There's also a blog post outlining the reasons why you shouldn't use key events to detect input.
Andy e
source share