Does anyone know how to make a textarea shrinkwrap the text inside on blur? The default number of columns is 10 or 15 and I want the textarea to adjust its width based on the text content.
I have tried the following code:
$('textarea').on('blur', function() {
var textAreaWidth = $(this).val().length;
$(this).attr('cols', 'textAreaWidth');
});
However, this solution is not ideal. I am looking for a better way to achieve this. Any ideas?