how to expand a text area when click on

后端 未结 9 1419
感情败类
感情败类 2021-02-02 10:17

Im working on a small project which has a textarea and i need help in making the text area expand on mouse click like that of twitter and facebook. the textarea should look lik

9条回答
  •  半阙折子戏
    2021-02-02 10:35

    This will work for you:

    
    

    I used onfocus instead of onclick because onclick isn't fired if the user uses the tab key to move to the textarea. You'll also want to make sure the user can't resize it themselves - hence the style attribute.

    You could also add onblur="this.rows=1;" to shrink it back down once the user moves out of your textarea.

提交回复
热议问题