how to expand a text area when click on

后端 未结 9 1295
感情败类
感情败类 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:46

    Something like this would work...

    Demo: http://jsfiddle.net/Y3rMM/

    CSS...

    .expand {
        height: 1em;
        width: 50%;
        padding: 3px;
    }
    

    HTML...

    
    

    jQuery...

    $('textarea.expand').focus(function () {
        $(this).animate({ height: "4em" }, 500);
    });
    

提交回复
热议问题