I have created a jQuery elastic plugin. I have the problem that if I write a word, such as “jQuery”, on the first line, and I press enter, the “jQuery” word will be hidden for a few milliseconds and then a new line will be inserted into the textarea.
My plugin page- http://jsfiddle.net/yash_wow/7F8aK/3/
Please help me solve this.
P.S. – I don’t want to use any other plugin and I don’t want code which inserts an extra line at the bottom of the textarea as all other elastic plugins do!
I did manage to tweak your plugin to work in Chrome here (untested on other browsers). Essentially I had to handle Enter in a special way to avoid it adding the new line to the bottom of the textbox and scrolling down to view it automatically before you get a chance to grow the textbox.
I also had to add the
.keyup()so that backspace worked as well.Here is the full javascript: